Skip to content

Commit 2a5fe3c

Browse files
committed
Avoid roundtrip to Text when inspecting x-forwarded-for header
1 parent 08d3b8e commit 2a5fe3c

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

Network/HTTP/ReverseProxy.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ import Data.Streaming.Network (AppData, readLens)
6363
import qualified Data.Text.Lazy as TL
6464
import qualified Data.Text.Lazy.Encoding as TLE
6565
import qualified Data.Text as T
66-
import qualified Data.Text.Encoding as TE
6766
import Data.Word8 (isSpace, _colon, _cr)
6867
import GHC.Generics (Generic)
6968
import Network.HTTP.Client (BodyReader, brRead)
@@ -362,7 +361,7 @@ fixReqHeaders wps req =
362361
fromSocket = (("X-Real-IP", S8.pack $ showSockAddr $ WAI.remoteHost req):)
363362
fromForwardedFor = do
364363
h <- lookup "x-forwarded-for" (WAI.requestHeaders req)
365-
listToMaybe $ map (TE.encodeUtf8 . T.strip) $ T.splitOn "," $ TE.decodeUtf8 h
364+
listToMaybe $ map S8.strip $ S8.split ',' h
366365
addXRealIP =
367366
case wpsSetIpHeader wps of
368367
SIHFromSocket -> fromSocket

0 commit comments

Comments
 (0)