Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixed bug in 'chunkedTransferEncoding'

  - Appended builders were also transfer encoded. This is now fixed.
  • Loading branch information...
commit 7bb714e7cb8066e93917144950d8076bf1d8d47a 1 parent 0db1237
Simon Meier authored
Showing with 13 additions and 5 deletions.
  1. +13 −5 Blaze/ByteString/Builder/HTTP.hs
18 Blaze/ByteString/Builder/HTTP.hs
View
@@ -111,6 +111,11 @@ test = flip (toLazyByteStringWith 32 32 32) L.empty
where
oneLine x = fromWriteSingleton writeWord32Hex x `mappend` Char8.fromChar ' '
+
+test = print $ toLazyByteString
+ $ chunkedTransferEncoding body `mappend` chunkedTransferTerminator
+
+body = copyByteString "maa" `mappend` copyByteString "foo" `mappend` copyByteString "bar"
-}
------------------------------------------------------------------------------
@@ -122,9 +127,10 @@ chunkedTransferEncoding :: Builder -> Builder
chunkedTransferEncoding (Builder b) =
fromBuildStepCont transferEncodingStep
where
- transferEncodingStep k = go (b (buildStep k))
+ finalStep !(BufRange op _) = return $ Done op ()
+
+ transferEncodingStep k = go (b (buildStep finalStep))
where
- go :: BuildStep a -> BufRange -> IO (BuildSignal a)
go innerStep !(BufRange op ope)
-- FIXME: Assert that outRemaining < maxBound :: Word32
| outRemaining < minimalBufferSize =
@@ -152,9 +158,10 @@ chunkedTransferEncoding (Builder b) =
-- execute inner builder with reduced boundaries
signal <- runBuildStep innerStep brInner
case signal of
- Done opInner' x ->
- wrapChunk opInner' $ \op' ->
- return $! done op' x
+ Done opInner' _ ->
+ wrapChunk opInner' $ \op' -> do
+ let !br' = BufRange op' ope
+ k br'
BufferFull minRequiredSize opInner' nextInnerStep ->
wrapChunk opInner' $ \op' ->
@@ -209,3 +216,4 @@ chunkedTransferEncoding (Builder b) =
chunkedTransferTerminator :: Builder
chunkedTransferTerminator = copyByteString "0\r\n\r\n"
+
Please sign in to comment.
Something went wrong with that request. Please try again.