Permalink
Browse files

Avoiding BS construction.

  • Loading branch information...
1 parent 85aaa7a commit 2fea7c055d401dfa54d383ae950c700548b7024b @kazu-yamamoto kazu-yamamoto committed Oct 4, 2012
Showing with 4 additions and 1 deletion.
  1. +4 −1 warp/Network/Wai/Handler/Warp/Conduit.hs
@@ -79,6 +79,9 @@ data ChunkState = NeedLen
| NeedLenNewline
| HaveLen Word
+bsCRLF :: L.ByteString
+bsCRLF = pack "\r\n"
+
chunkedSource :: MonadIO m
=> I.IORef (ResumableSource m ByteString, ChunkState)
-> Source m ByteString
@@ -99,7 +102,7 @@ chunkedSource ipair = do
-- Drop the final CRLF
(src', ()) <- lift $ src $$++ do
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)
go src (HaveLen len) = do
(src', mbs) <- lift $ src $$++ CL.head

0 comments on commit 2fea7c0

Please sign in to comment.