Skip to content

Commit

Permalink
[twitter#84] Fix issue where HttpDechunker could send EOF while other…
Browse files Browse the repository at this point in the history
… chunks have not yet been read.
  • Loading branch information
stephenjudkins committed May 10, 2012
1 parent 5aa5ea6 commit 1d98f36
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ class HttpDechunker extends BrokerChannelHandler {
ch: Channel,
out: Broker[ChannelBuffer],
err: Broker[Throwable],
close: Offer[Unit])
close: Offer[Unit]
lastWrite: Offer[Unit])
{
Offer.select(
close { _=>
Expand All @@ -36,15 +37,15 @@ class HttpDechunker extends BrokerChannelHandler {
if (content.readable)
out.send(content)
else
Offer.const(())
lastWrite

if (chunk.isLast) {
ch.close()
sendOf andThen error(err, EOF)
} else {
ch.setReadable(false)
sendOf andThen ch.setReadable(true)
read(ch, out, err, close)
read(ch, out, err, close, sendOf)
}

case MessageValue(invalid, ctx) =>
Expand All @@ -63,7 +64,7 @@ class HttpDechunker extends BrokerChannelHandler {

case e =>
e.sendUpstream()
read(ch, out, err, close)
read(ch, out, err, close, lastWrite)
}
)
}
Expand Down Expand Up @@ -91,7 +92,7 @@ class HttpDechunker extends BrokerChannelHandler {
}

Channels.fireMessageReceived(ctx, res)
read(ctx.getChannel, out, err, close.recv)
read(ctx.getChannel, out, err, close.recv, Offer.const(()))

case MessageValue(invalid, ctx) =>
Channels.fireExceptionCaught(
Expand Down

0 comments on commit 1d98f36

Please sign in to comment.