Fix a bug where HttpContentDecoder emits duplicate HttpMessage or raises NPE

This commit is contained in:
Trustin Lee 2013-02-10 01:35:01 +09:00
parent 61bbb04852
commit 27190fcb7f
2 changed files with 9 additions and 5 deletions

View File

@ -56,7 +56,7 @@ public abstract class HttpContentDecoder extends MessageToMessageDecoder<HttpObj
if (msg instanceof HttpMessage) {
assert message == null;
message = (HttpMessage) msg;
decodeStarted = false;
cleanup();
}
@ -100,11 +100,15 @@ public abstract class HttpContentDecoder extends MessageToMessageDecoder<HttpObj
}
return new Object[] { message, c };
}
return decodeContent(null, c);
if (decoder != null) {
return decodeContent(null, c);
} else {
return c;
}
}
// Because FullHttpMessage and HttpChunk is a mutable object, we can simply forward it.
return msg;
return null;
}
@Override

View File

@ -56,7 +56,7 @@ public class HttpSnoopClientInitializer extends ChannelInitializer<SocketChannel
p.addLast("inflater", new HttpContentDecompressor());
// Uncomment the following line if you don't want to handle HttpChunks.
//pipeline.addLast("aggregator", new HttpChunkAggregator(1048576));
//p.addLast("aggregator", new HttpObjectAggregator(1048576));
p.addLast("handler", new HttpSnoopClientHandler());
}