Skip to content

Commit

Permalink
Merge branch 'fix-chunked-transfer-encoding'
Browse files Browse the repository at this point in the history
  • Loading branch information
meiersi committed Jan 7, 2011
2 parents 5a33dd9 + 2bb840c commit 1253baf
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
18 changes: 13 additions & 5 deletions Blaze/ByteString/Builder/HTTP.hs
Expand Up @@ -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"
-}

------------------------------------------------------------------------------
Expand All @@ -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 =
Expand Down Expand Up @@ -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' ->
Expand Down Expand Up @@ -209,3 +216,4 @@ chunkedTransferEncoding (Builder b) =
chunkedTransferTerminator :: Builder
chunkedTransferTerminator = copyByteString "0\r\n\r\n"


5 changes: 5 additions & 0 deletions CHANGES
@@ -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".
Expand Down
2 changes: 1 addition & 1 deletion blaze-builder.cabal
@@ -1,5 +1,5 @@
Name: blaze-builder
Version: 0.2.1.3
Version: 0.2.1.4
Synopsis: Efficient buffered output.

Description:
Expand Down

0 comments on commit 1253baf

Please sign in to comment.