on master help sign in
adding necessary HeaderName.
ad15865Kazu Yamamoto
warp/Network/Wai/Handler/Warp/Request.hs+2−2
@@ -67,14 +67,14 @@ parseRequest' conn port (firstLine:otherLines) remoteHost' src = do
67 heads <- liftIO
67 heads <- liftIO
68 $ handleExpect conn httpversion id
68 $ handleExpect conn httpversion id
69 (map parseHeaderNoAttr otherLines)
69 (map parseHeaderNoAttr otherLines)
70− let host = fromMaybe host' $ lookup "host" heads
70+ let host = fromMaybe host' $ lookup hHost heads
71 let len0 =
71 let len0 =
72 case lookup H.hContentLength heads of
72 case lookup H.hContentLength heads of
73 Nothing -> 0
73 Nothing -> 0
74 Just bs -> readInt bs
74 Just bs -> readInt bs
75 let serverName' = takeUntil 58 host -- ':'
75 let serverName' = takeUntil 58 host -- ':'
76 let chunked = maybe False ((== "chunked") . CI.foldCase)
76 let chunked = maybe False ((== "chunked") . CI.foldCase)
77− $ lookup "transfer-encoding" heads
77+ $ lookup hTransferEncoding heads
78 (rbody, getSource) <- liftIO $
78 (rbody, getSource) <- liftIO $
79 if chunked
79 if chunked
80 then do
80 then do
warp/Network/Wai/Handler/Warp/Types.hs+18
@@ -1,4 +1,5 @@
1{-# LANGUAGE DeriveDataTypeable #-}
1{-# LANGUAGE DeriveDataTypeable #-}
2+{-# LANGUAGE OverloadedStrings #-}
2
3
3module Network.Wai.Handler.Warp.Types where
4module Network.Wai.Handler.Warp.Types where
4
5
@@ -7,14 +8,29 @@ import Data.ByteString (ByteString)
7import qualified Data.ByteString.Char8 as B
8import qualified Data.ByteString.Char8 as B
8import Data.Typeable (Typeable)
9import Data.Typeable (Typeable)
9import Data.Version (showVersion)
10import Data.Version (showVersion)
11+import Network.HTTP.Types.Header
10import qualified Paths_warp
12import qualified Paths_warp
11
13
14+----------------------------------------------------------------
15+
12warpVersion :: String
16warpVersion :: String
13warpVersion = showVersion Paths_warp.version
17warpVersion = showVersion Paths_warp.version
14
18
19+----------------------------------------------------------------
20+
15-- | TCP port number
21-- | TCP port number
16type Port = Int
22type Port = Int
17
23
24+----------------------------------------------------------------
25+
26+hTransferEncoding :: HeaderName
27+hTransferEncoding = "Transfer-Encoding"
28+
29+hHost :: HeaderName
30+hHost = "Host"
31+
32+----------------------------------------------------------------
33+
18data InvalidRequest =
34data InvalidRequest =
19 NotEnoughLines [String]
35 NotEnoughLines [String]
20 | BadFirstLine String
36 | BadFirstLine String
@@ -26,6 +42,8 @@ data InvalidRequest =
26
42
27instance Exception InvalidRequest
43instance Exception InvalidRequest
28
44
45+----------------------------------------------------------------
46+
29-- |
47-- |
30--
48--
31-- In order to provide slowloris protection, Warp provides timeout handlers. We
49-- In order to provide slowloris protection, Warp provides timeout handlers. We