on master help sign in
conduit changes: no more Prepared
commit6f8cc642b2716b29fa373c4575bf86c04624531e authorMichael Snoyman <michael@snoyman.com> dateSat 28 Jan 2012, 22:29 (15 years ago) parent67bb38e
4 files changed+13−13
conduit+1−1 wai-extra/Network/Wai/Handler/CGI.hs+1−1 wai-extra/Network/Wai/Parse.hs+1−1 warp/Network/Wai/Handler/Warp.hs+10−10
conduit+1−1

Submodule changed.

wai-extra/Network/Wai/Handler/CGI.hs+1−1
@@ -141,7 +141,7 @@ runGeneric vars inputH outputH xsendfile app = do
141141 , fromByteString sf
142142 , fromByteString " not supported"
143143 ]
144− bsSink = C.Sink $ return $ C.SinkData push (return ())
144+ bsSink = C.SinkData push (return ())
145145 push (C.Chunk bs) = do
146146 liftIO $ outputH bs
147147 return $ C.Processing push (return ())
wai-extra/Network/Wai/Parse.hs+1−1
@@ -156,7 +156,7 @@ conduitRequestBody :: BackEnd y
156156 -> C.Conduit S.ByteString IO (Either Param (File y))
157157conduitRequestBody sink req = do
158158 case ctype of
159− Nothing -> C.Conduit $ return $ C.PreparedConduit
159+ Nothing -> C.Conduit
160160 { C.conduitPush = \bs -> return $ C.Finished (Just bs) []
161161 , C.conduitClose = return []
162162 }
warp/Network/Wai/Handler/Warp.hs+10−10
@@ -264,7 +264,7 @@ serveConnection settings th onException port app conn remoteHost' =
264264 where
265265 serveConnection' :: ResourceT IO ()
266266 serveConnection' = do
267− fromClient <- C.bufferSource $ C.Source $ return $ connSource conn th
267+ fromClient <- C.bufferSource $ connSource conn th
268268 serveConnection'' fromClient
269269
270270 serveConnection'' fromClient = do
@@ -335,7 +335,7 @@ parseRequest' port (firstLine:otherLines) remoteHost' src = do
335335 -- We can't use the standard isolate, as its counter is not
336336 -- kept in a mutable variable.
337337 lenRef <- liftIO $ I.newIORef len0
338− let isolate = C.Conduit $ return $ C.PreparedConduit push close
338+ let isolate = C.Conduit push close
339339 push bs = do
340340 len <- liftIO $ I.readIORef lenRef
341341 let (a, b) = S.splitAt len bs
@@ -343,10 +343,9 @@ parseRequest' port (firstLine:otherLines) remoteHost' src = do
343343 liftIO $ I.writeIORef lenRef len'
344344 return $ if len' == 0
345345 then C.Finished (if S.null b then Nothing else Just b) (if S.null a then [] else [a])
346− else C.Producing push close [a]
346+ else C.Producing isolate [a]
347347 close = return []
348− psrc <- C.prepareSource $ src C.$= isolate
349− return $ C.Source $ return psrc
348+ return $ src C.$= isolate
350349 return Request
351350 { requestMethod = method
352351 , httpVersion = httpversion
@@ -524,12 +523,13 @@ sendResponse th req conn r = sendResponse' r
524523 return $ isKeepAlive hs
525524 needsChunked' = needsChunked hs
526525 chunk :: C.Conduit Builder IO Builder
527− chunk = C.Conduit $ return C.PreparedConduit
526+ chunk = C.Conduit
528527 { C.conduitPush = push
529528 , C.conduitClose = close
530529 }
531530
532− push x = return $ C.Producing push close [chunkedTransferEncoding x]
531+ conduit = C.Conduit push close
532+ push x = return $ C.Producing conduit [chunkedTransferEncoding x]
533533 close = return [chunkedTransferTerminator]
534534
535535parseHeaderNoAttr :: ByteString -> H.Header
@@ -542,11 +542,11 @@ parseHeaderNoAttr s =
542542 else rest
543543 in (CI.mk k, rest')
544544
545−connSource :: Connection -> T.Handle -> C.PreparedSource IO ByteString
545+connSource :: Connection -> T.Handle -> C.Source IO ByteString
546546connSource Connection { connRecv = recv } th =
547547 src
548548 where
549− src = C.PreparedSource
549+ src = C.Source
550550 { C.sourcePull = do
551551 bs <- liftIO recv
552552 if S.null bs
@@ -560,7 +560,7 @@ connSource Connection { connRecv = recv } th =
560560-- | Use 'connSendAll' to send this data while respecting timeout rules.
561561connSink :: Connection -> T.Handle -> C.Sink B.ByteString IO ()
562562connSink Connection { connSendAll = send } th =
563− C.Sink $ return $ C.SinkData push close
563+ C.SinkData push close
564564 where
565565 close = liftIO (T.resume th)
566566 push x = do