[#1410] Make sure we generate a Http response if the server writes back 200 response with empty body and and close the connection
This commit is contained in:
parent
d1a3806ebd
commit
1e5f266a3c
@ -449,7 +449,8 @@ public abstract class HttpObjectDecoder extends ReplayingDecoder<HttpObjectDecod
|
|||||||
private void reset() {
|
private void reset() {
|
||||||
reset(null);
|
reset(null);
|
||||||
}
|
}
|
||||||
private void reset(MessageList<Object> out) {
|
|
||||||
|
protected final void reset(MessageList<Object> out) {
|
||||||
if (out != null) {
|
if (out != null) {
|
||||||
HttpMessage message = this.message;
|
HttpMessage message = this.message;
|
||||||
ByteBuf content = this.content;
|
ByteBuf content = this.content;
|
||||||
|
@ -16,7 +16,9 @@
|
|||||||
package io.netty.handler.codec.http;
|
package io.netty.handler.codec.http;
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.channel.ChannelPipeline;
|
import io.netty.channel.ChannelPipeline;
|
||||||
|
import io.netty.channel.MessageList;
|
||||||
import io.netty.handler.codec.TooLongFrameException;
|
import io.netty.handler.codec.TooLongFrameException;
|
||||||
|
|
||||||
|
|
||||||
@ -117,4 +119,20 @@ public class HttpResponseDecoder extends HttpObjectDecoder {
|
|||||||
protected boolean isDecodingRequest() {
|
protected boolean isDecodingRequest() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void decodeLast(ChannelHandlerContext ctx, ByteBuf in, MessageList<Object> out) throws Exception {
|
||||||
|
super.decodeLast(ctx, in, out);
|
||||||
|
MessageList<Object> msgs = MessageList.newInstance();
|
||||||
|
reset(msgs);
|
||||||
|
if (!msgs.isEmpty()) {
|
||||||
|
// Handle the case where the server sends an empty 200 response and close the connection
|
||||||
|
// https://github.com/netty/netty/issues/1410
|
||||||
|
HttpResponse response = (HttpResponse) msgs.get(0);
|
||||||
|
if (response.getStatus().code() == 200) {
|
||||||
|
out.add(msgs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
msgs.recycle();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user