on master help sign in
Using getRequestBodyChunk instead of requestBody.
commitd5898ee51ca7940eba9738f0d7edc8823164687e authorKazu Yamamoto <kazu@iij.ad.jp> dateFri 26 Apr 2019, 12:54 (7 years ago) parent80158ac
2 files changed+11−10
warp/Network/Wai/Handler/Warp/HTTP2/Worker.hs+2−2 warp/test/RunSpec.hs+9−8
warp/Network/Wai/Handler/Warp/HTTP2/Worker.hs+2−2
@@ -24,7 +24,7 @@ import Network.HTTP2
2424import Network.HTTP2.Priority
2525import Network.Wai
2626import qualified Network.Wai.Handler.Warp.Timeout as Timeout
27−import Network.Wai.Internal (Response(..), ResponseReceived(..), ResponseReceived(..))
27+import Network.Wai.Internal (Response(..), ResponseReceived(..), ResponseReceived(..), getRequestBodyChunk)
2828
2929import Network.Wai.Handler.Warp.FileInfoCache
3030import Network.Wai.Handler.Warp.HTTP2.EncodeFrame
@@ -247,7 +247,7 @@ worker ctx@Context{inputQ,controlQ} set app responder tm = do
247247 T.resume th
248248 T.tickle th
249249 let !ii' = ii { threadHandle = th }
250− !body = requestBody req
250+ !body = getRequestBodyChunk req
251251 !body' = do
252252 T.pause th
253253 bs <- body
warp/test/RunSpec.hs+9−8
@@ -22,6 +22,7 @@ import Network.HTTP.Types
2222import Network.Socket
2323import Network.Socket.ByteString (sendAll)
2424import Network.Wai hiding (responseHeaders)
25+import Network.Wai.Internal (getRequestBodyChunk)
2526import Network.Wai.Handler.Warp
2627import System.IO.Unsafe (unsafePerformIO)
2728import System.Timeout (timeout)
@@ -85,7 +86,7 @@ err icount msg = liftIO $ I.writeIORef icount $ Left $ show msg
8586
8687readBody :: CounterApplication
8788readBody icount req f = do
88− body <- consumeBody $ requestBody req
89+ body <- consumeBody $ getRequestBodyChunk req
8990 case () of
9091 ()
9192 | pathInfo req == ["hello"] && L.fromChunks body /= "Hello"
@@ -106,8 +107,8 @@ ignoreBody icount req f = do
106107
107108doubleConnect :: CounterApplication
108109doubleConnect icount req f = do
109− _ <- consumeBody $ requestBody req
110− _ <- consumeBody $ requestBody req
110+ _ <- consumeBody $ getRequestBodyChunk req
111+ _ <- consumeBody $ getRequestBodyChunk req
111112 incr icount
112113 f $ responseLBS status200 [] "double connect"
113114
@@ -277,7 +278,7 @@ spec = do
277278 countVar <- newTVarIO (0 :: Int)
278279 ifront <- I.newIORef id
279280 let app req f = do
280− bss <- consumeBody $ requestBody req
281+ bss <- consumeBody $ getRequestBodyChunk req
281282 liftIO $ I.atomicModifyIORef ifront $ \front -> (front . (S.concat bss:), ())
282283 atomically $ modifyTVar countVar (+ 1)
283284 f $ responseLBS status200 [] ""
@@ -305,7 +306,7 @@ spec = do
305306 ifront <- I.newIORef id
306307 countVar <- newTVarIO (0 :: Int)
307308 let app req f = do
308− bss <- consumeBody $ requestBody req
309+ bss <- consumeBody $ getRequestBodyChunk req
309310 I.atomicModifyIORef ifront $ \front -> (front . (S.concat bss:), ())
310311 atomically $ modifyTVar countVar (+ 1)
311312 f $ responseLBS status200 [] ""
@@ -328,7 +329,7 @@ spec = do
328329 ifront <- I.newIORef id
329330 countVar <- newTVarIO (0 :: Int)
330331 let app req f = do
331− bss <- consumeBody $ requestBody req
332+ bss <- consumeBody $ getRequestBodyChunk req
332333 liftIO $ I.atomicModifyIORef ifront $ \front -> (front . (S.concat bss:), ())
333334 atomically $ modifyTVar countVar (+ 1)
334335 f $ responseLBS status200 [] ""
@@ -354,7 +355,7 @@ spec = do
354355 it "timeout in request body" $ do
355356 ifront <- I.newIORef id
356357 let app req f = do
357− bss <- (consumeBody $ requestBody req) `onException`
358+ bss <- (consumeBody $ getRequestBodyChunk req) `onException`
358359 liftIO (I.atomicModifyIORef ifront (\front -> (front . ("consume interrupted":), ())))
359360 liftIO $ threadDelay 4000000 `E.catch` \e -> do
360361 I.atomicModifyIORef ifront (\front ->
@@ -419,7 +420,7 @@ spec = do
419420 countVar <- newTVarIO (0 :: Int)
420421 let app req f = f $ responseStream status200 [] $ \write _ -> do
421422 let loop = do
422− bs <- requestBody req
423+ bs <- getRequestBodyChunk req
423424 unless (S.null bs) $ do
424425 write $ byteString bs
425426 atomically $ modifyTVar countVar (+ 1)