[#1101] Fix NPE which accour when send a 100-continue response and using the HttpContentEncoder
This commit is contained in:
parent
977b6f3a28
commit
b6038534cc
@ -54,7 +54,7 @@ public abstract class HttpContentEncoder extends MessageToMessageCodec<HttpMessa
|
|||||||
private EmbeddedByteChannel encoder;
|
private EmbeddedByteChannel encoder;
|
||||||
private HttpMessage message;
|
private HttpMessage message;
|
||||||
private boolean encodeStarted;
|
private boolean encodeStarted;
|
||||||
|
private boolean continueResponse;
|
||||||
@Override
|
@Override
|
||||||
protected Object decode(ChannelHandlerContext ctx, HttpMessage msg)
|
protected Object decode(ChannelHandlerContext ctx, HttpMessage msg)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
@ -71,6 +71,18 @@ public abstract class HttpContentEncoder extends MessageToMessageCodec<HttpMessa
|
|||||||
protected Object encode(ChannelHandlerContext ctx, HttpObject msg)
|
protected Object encode(ChannelHandlerContext ctx, HttpObject msg)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
if (msg instanceof HttpResponse && ((HttpResponse) msg).getStatus().code() == 100) {
|
if (msg instanceof HttpResponse && ((HttpResponse) msg).getStatus().code() == 100) {
|
||||||
|
// 100-continue response must be passed through.
|
||||||
|
BufUtil.retain(msg);
|
||||||
|
if (!(msg instanceof LastHttpContent)) {
|
||||||
|
continueResponse = true;
|
||||||
|
}
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (continueResponse) {
|
||||||
|
if (msg instanceof LastHttpContent) {
|
||||||
|
continueResponse = false;
|
||||||
|
}
|
||||||
// 100-continue response must be passed through.
|
// 100-continue response must be passed through.
|
||||||
BufUtil.retain(msg);
|
BufUtil.retain(msg);
|
||||||
return msg;
|
return msg;
|
||||||
|
Loading…
Reference in New Issue
Block a user