on master help sign in
Avoiding BS construction.
commit2fea7c055d401dfa54d383ae950c700548b7024b authorKazu Yamamoto <kazu@iij.ad.jp> dateThu 4 Oct 2012, 16:26 (14 years ago) parent85aaa7a
1 file changed+4−1
warp/Network/Wai/Handler/Warp/Conduit.hs+4−1
warp/Network/Wai/Handler/Warp/Conduit.hs+4−1
@@ -79,6 +79,9 @@ data ChunkState = NeedLen
7979 | NeedLenNewline
8080 | HaveLen Word
8181
82+bsCRLF :: L.ByteString
83+bsCRLF = pack "\r\n"
84+
8285chunkedSource :: MonadIO m
8386 => I.IORef (ResumableSource m ByteString, ChunkState)
8487 -> Source m ByteString
@@ -99,7 +102,7 @@ chunkedSource ipair = do
99102 -- Drop the final CRLF
100103 (src', ()) <- lift $ src $$++ do
101104 crlf <- CB.take 2
102− unless (crlf == pack "\r\n") $ leftover $ S.concat $ L.toChunks crlf
105+ unless (crlf == bsCRLF) $ leftover $ S.concat $ L.toChunks crlf
103106 liftIO $ I.writeIORef ipair (src', HaveLen 0)
104107 go src (HaveLen len) = do
105108 (src', mbs) <- lift $ src $$++ CL.head