Skip to content

Commit

Permalink
warp: use 'isMultiline' instead of 'p' and inline 'addLine'
Browse files Browse the repository at this point in the history
  • Loading branch information
Vlix committed Jan 4, 2024
1 parent 4f5890a commit 5092f23
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions warp/Network/Wai/Handler/Warp/Request.hs
Original file line number Diff line number Diff line change
Expand Up @@ -293,16 +293,16 @@ push maxTotalHeaderLength src (THStatus totalLen chunkLen reqLines prepend) bs
0 -> True
1 -> SU.unsafeHead bs == _cr
_ -> False
addEither p =
if p then addChunk else addLine
-- addLine: take the current chunk and add to 'lines' as optimal as possible
addLine len chunk =
let newTotal = currentTotal + len
newLine =
if chunkLen == 0
then chunk
else S.toStrict $ B.toLazyByteString $ prepend $ B.byteString chunk
in THStatus newTotal 0 (reqLines . (newLine:)) id
addEither isMultiline len chunk
| isMultiline = addChunk len chunk
-- addLine: take the current chunk and add to 'lines' as optimal as possible
| otherwise =
let newTotal = currentTotal + len
toBS = S.toStrict . B.toLazyByteString
newLine =
if chunkLen == 0 then chunk else toBS $ prepend $ B.byteString chunk
in THStatus newTotal 0 (reqLines . (newLine:)) id
{-# INLINE addChunk #-}
-- addChunk: take the current chunk and add to 'prepend' as optimal as possible
addChunk len chunk =
let newChunkTotal = chunkLen + len
Expand Down

0 comments on commit 5092f23

Please sign in to comment.