Permalink
Browse files

Merge branch 'fix-chunked-transfer-encoding'

  • Loading branch information...
2 parents 5a33dd9 + 2bb840c commit 1253baff6426827dd9bab86b9200244fe6b109bf @meiersi committed Jan 7, 2011
Showing with 19 additions and 6 deletions.
  1. +13 −5 Blaze/ByteString/Builder/HTTP.hs
  2. +5 −0 CHANGES
  3. +1 −1 blaze-builder.cabal
@@ -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"
+
View
@@ -1,3 +1,8 @@
+* 0.2.1.4
+
+ - Fixed bug: appending to 'chunkedTransferEncoding somebuilder' also encoded
+ the appended builder, which is obviously wrong.
+
* 0.2.1.3
- Fixed bug: 'chunkedTransferTerminator' is now correctly set to "0\r\n\r\n".
View
@@ -1,5 +1,5 @@
Name: blaze-builder
-Version: 0.2.1.3
+Version: 0.2.1.4
Synopsis: Efficient buffered output.
Description:

0 comments on commit 1253baf

Please sign in to comment.