Skip to content

Commit

Permalink
Avoiding BS construction.
Browse files Browse the repository at this point in the history
  • Loading branch information
kazu-yamamoto committed Oct 4, 2012
1 parent 85aaa7a commit 2fea7c0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion warp/Network/Wai/Handler/Warp/Conduit.hs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ data ChunkState = NeedLen
| NeedLenNewline | NeedLenNewline
| HaveLen Word | HaveLen Word


bsCRLF :: L.ByteString
bsCRLF = pack "\r\n"

chunkedSource :: MonadIO m chunkedSource :: MonadIO m
=> I.IORef (ResumableSource m ByteString, ChunkState) => I.IORef (ResumableSource m ByteString, ChunkState)
-> Source m ByteString -> Source m ByteString
Expand All @@ -99,7 +102,7 @@ chunkedSource ipair = do
-- Drop the final CRLF -- Drop the final CRLF
(src', ()) <- lift $ src $$++ do (src', ()) <- lift $ src $$++ do
crlf <- CB.take 2 crlf <- CB.take 2
unless (crlf == pack "\r\n") $ leftover $ S.concat $ L.toChunks crlf unless (crlf == bsCRLF) $ leftover $ S.concat $ L.toChunks crlf
liftIO $ I.writeIORef ipair (src', HaveLen 0) liftIO $ I.writeIORef ipair (src', HaveLen 0)
go src (HaveLen len) = do go src (HaveLen len) = do
(src', mbs) <- lift $ src $$++ CL.head (src', mbs) <- lift $ src $$++ CL.head
Expand Down

0 comments on commit 2fea7c0

Please sign in to comment.