@@ -14,13 +14,12 @@ import qualified Data.ByteString.Unsafe as SU
1414import qualified Data.CaseInsensitive as CI
1515import Data.Conduit
1616import qualified Data.IORef as I
17−import Data.Maybe (fromMaybe)
1817import Data.Monoid (mempty)
19−import Data.Void (Void)
2018import Data.Word (Word8)
2119import qualified Network.HTTP.Types as H
2220import Network.Socket (SockAddr)
2321import Network.Wai
22+import Network.Wai.Internal
2423import Network.Wai.Handler.Warp.Conduit
2524import Network.Wai.Handler.Warp.ReadInt
2625import Network.Wai.Handler.Warp.Types
@@ -36,12 +35,12 @@ parseRequest
3635 :: Connection
3736 -> Timeout.Handle
3837 -> Res.InternalState
39− -> Port -> SockAddr
38+ -> SockAddr
4039 -> Source IO ByteString
4140 -> IO (Request, IO (ResumableSource IO ByteString))
42−parseRequest conn timeoutHandle internalState port remoteHost' src1 = do
41+parseRequest conn timeoutHandle internalState remoteHost' src1 = do
4342 (src2, headers') <- src1 $$+ takeHeaders
44− parseRequest' conn timeoutHandle internalState port headers' remoteHost' src2
43+ parseRequest' conn timeoutHandle internalState headers' remoteHost' src2
4544
4645handleExpect :: Connection
4746 -> H.HttpVersion
@@ -61,27 +60,24 @@ handleExpect conn hv front (x:xs) = handleExpect conn hv (front . (x:)) xs
6160parseRequest' :: Connection
6261 -> Timeout.Handle
6362 -> Res.InternalState
64− -> Port
6563 -> [ByteString]
6664 -> SockAddr
6765 -> ResumableSource IO ByteString -- FIXME was buffered
6866 -> IO (Request, IO (ResumableSource IO ByteString))
69−parseRequest' _ _ _ _ [] _ _ = throwIO $ NotEnoughLines []
70−parseRequest' conn timeoutHandle internalState port (firstLine:otherLines) remoteHost' src = do
67+parseRequest' _ _ _ [] _ _ = throwIO $ NotEnoughLines []
68+parseRequest' conn timeoutHandle internalState (firstLine:otherLines) remoteHost' src = do
7169 (method, rpath', gets, httpversion) <- parseFirst firstLine
72− let (host',rpath)
73− | S.null rpath' = ("", "/")
74− | "http://" `S.isPrefixOf` rpath' = S.breakByte 47 $ S.drop 7 rpath'
75− | otherwise = ("", rpath')
70+ let rpath
71+ | S.null rpath' = "/"
72+ | "http://" `S.isPrefixOf` rpath' = snd $ S.breakByte 47 $ S.drop 7 rpath'
73+ | otherwise = rpath'
7674 heads <- liftIO
7775 $ handleExpect conn httpversion id
7876 (map parseHeaderNoAttr otherLines)
79− let host = fromMaybe host' $ lookup hHost heads
8077 let len0 =
8178 case lookup H.hContentLength heads of
8279 Nothing -> 0
8380 Just bs -> readInt bs
84− let serverName' = takeUntil 58 host -- ':'
8581 let chunked = maybe False ((== "chunked") . CI.foldCase)
8682 $ lookup hTransferEncoding heads
8783 (rbody, getSource) <-
@@ -100,8 +96,6 @@ parseRequest' conn timeoutHandle internalState port (firstLine:otherLines) remot
10096 , rawPathInfo = rpath
10197 , rawQueryString = gets
10298 , queryString = H.parseQuery gets
103− , serverName = serverName'
104− , serverPort = port
10599 , requestHeaders = heads
106100 , isSecure = False
107101 , remoteHost = remoteHost'