on master help sign in
Warp test suite passes again
commite67d64ca1308cd9757dafc063cd91c79316d8c85 authorMichael Snoyman <michael@snoyman.com> dateThu 22 May 2014, 10:27 (12 years ago) parentf6107c1
2 files changed+6−22
warp/Network/Wai/Handler/Warp/Response.hs+4−20 warp/test/RunSpec.hs+2−2
warp/Network/Wai/Handler/Warp/Response.hs+4−20
@@ -167,7 +167,7 @@ sendResponse conn ii req reqidxhdr src response = do
167167 T.tickle th
168168 return ret
169169 else do
170− sendResponseNoBody conn ver s hs response
170+ sendResponseNoBody conn ver s hs
171171 T.tickle th
172172 return isPersist
173173 where
@@ -196,7 +196,7 @@ sendResponse conn ii req reqidxhdr src response = do
196196
197197data Rsp = RspFile FilePath (Maybe FilePart) (Maybe HeaderValue) (IO ())
198198 | RspBuilder Builder Bool
199− | RspStream ((Maybe Builder -> IO ()) -> IO ()) Bool T.Handle
199+ | RspStream StreamingBody Bool T.Handle
200200 | RspRaw (IO ByteString -> (ByteString -> IO ()) -> IO ()) (IO ByteString) (IO ())
201201
202202----------------------------------------------------------------
@@ -250,9 +250,7 @@ sendRsp conn ver s hs (RspStream withBodyFlush needsChunked th) = do
250250 loop
251251 loop
252252 addChunk header
253− withBodyFlush $ \mbuilder -> addChunk $ case mbuilder of
254− Nothing -> flush
255− Just builder -> chunkedTransferEncoding builder
253+ withBodyFlush (addChunk . chunkedTransferEncoding) (addChunk flush)
256254 when needsChunked $ addChunk chunkedTransferTerminator
257255 mbs <- finish
258256 maybe (return ()) (connSink conn th) mbs
@@ -274,22 +272,8 @@ sendResponseNoBody :: Connection
274272 -> H.HttpVersion
275273 -> H.Status
276274 -> H.ResponseHeaders
277− -> Response
278275 -> IO ()
279−sendResponseNoBody conn ver s hs (ResponseStream _ _ withBodyFlush) = do
280− -- Allow the application to free resources
281− withBodyFlush $ const $ return ()
282−
283− composeHeader ver s hs >>= connSendAll conn
284−sendResponseNoBody conn ver s hs (ResponseRaw withRaw _) = do
285− -- Allow the application to free resources
286− withRaw (return S.empty) (const $ return ())
287−
288− composeHeader ver s hs >>= connSendAll conn
289−sendResponseNoBody conn ver s hs ResponseBuilder{} =
290− composeHeader ver s hs >>= connSendAll conn
291−sendResponseNoBody conn ver s hs ResponseFile{} =
292− composeHeader ver s hs >>= connSendAll conn
276+sendResponseNoBody conn ver s hs = composeHeader ver s hs >>= connSendAll conn
293277
294278----------------------------------------------------------------
295279----------------------------------------------------------------
warp/test/RunSpec.hs+2−2
@@ -354,11 +354,11 @@ spec = do
354354 `shouldBe` ["date"]
355355
356356 it "streaming echo #249" $ do
357− let app req f = f $ responseStream status200 [] $ \write -> do
357+ let app req f = f $ responseStream status200 [] $ \write _ -> do
358358 let loop = do
359359 bs <- requestBody req
360360 unless (S.null bs) $ do
361− write $ Just $ fromByteString bs
361+ write $ fromByteString bs
362362 loop
363363 loop
364364 withApp defaultSettings app $ \port -> do