on master help sign in
Exposing drainRequestBody
4e053c6Michael Snoyman
Network/Wai/Handler/Warp.hs+8−2
@@ -18,6 +18,7 @@ module Network.Wai.Handler.Warp
18 ( run
18 ( run
19 , sendResponse
19 , sendResponse
20 , parseRequest
20 , parseRequest
21+ , drainRequestBody
21 ) where
22 ) where
22
23
23import Network.Wai
24import Network.Wai
@@ -81,8 +82,7 @@ serveConnection port app conn remoteHost' = do
81 where serveConnection' = do
82 where serveConnection' = do
82 (ilen, env) <- parseRequest port conn remoteHost'
83 (ilen, env) <- parseRequest port conn remoteHost'
83 res <- app env
84 res <- app env
84− remaining <- readIORef ilen
85+ drainRequestBody conn ilen
85− _ <- B.hGet conn remaining -- FIXME just skip, don't read
86 keepAlive <- sendResponse env (httpVersion env) conn res
86 keepAlive <- sendResponse env (httpVersion env) conn res
87 hFlush conn
87 hFlush conn
88 when keepAlive serveConnection'
88 when keepAlive serveConnection'
@@ -93,6 +93,12 @@ serveConnection port app conn remoteHost' = do
93 Nothing -> ioError e
93 Nothing -> ioError e
94 | otherwise = ioError e
94 | otherwise = ioError e
95
95
96+drainRequestBody :: Handle -> IORef Int -> IO ()
97+drainRequestBody conn ilen = do
98+ remaining <- readIORef ilen
99+ _ <- B.hGet conn remaining -- FIXME just skip, don't read
100+ return ()
101+
96parseRequest :: Port -> Handle -> String -> IO (IORef Int, Request)
102parseRequest :: Port -> Handle -> String -> IO (IORef Int, Request)
97parseRequest port conn remoteHost' = do
103parseRequest port conn remoteHost' = do
98 headers' <- takeUntilBlank conn id
104 headers' <- takeUntilBlank conn id