Skip to content

Commit

Permalink
Merge #3386 into 1.2.0-M5
Browse files Browse the repository at this point in the history
  • Loading branch information
violetagg committed Aug 7, 2024
2 parents 26584c0 + 1f8a48a commit deea698
Showing 1 changed file with 19 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,7 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) {
}
}

DecoderResult decoderResult = request.decoderResult();
if (decoderResult.isFailure()) {
sendDecodingFailures(decoderResult.cause(), msg, validateHeaders);
if (handleDecodingFailures(request.decoderResult(), msg, validateHeaders)) {
return;
}

Expand Down Expand Up @@ -275,13 +273,16 @@ else if (persistentConnection && pendingResponses == 0) {
if (msg == EMPTY_LAST_CONTENT) {
ctx.fireChannelRead(msg);
}
else if (msg.getClass() == DefaultLastHttpContent.class) {
if (handleDecodingFailures(((DefaultLastHttpContent) msg).decoderResult(), msg, validateHeaders)) {
return;
}
ctx.fireChannelRead(msg);
}
else if (msg instanceof LastHttpContent) {
DecoderResult decoderResult = ((LastHttpContent) msg).decoderResult();
if (decoderResult.isFailure()) {
sendDecodingFailures(decoderResult.cause(), msg, validateHeaders);
if (handleDecodingFailures(((LastHttpContent) msg).decoderResult(), msg, validateHeaders)) {
return;
}

ctx.fireChannelRead(msg);
}
else {
Expand All @@ -307,12 +308,9 @@ else if (overflow) {
return;
}

if (msg instanceof DecoderResultProvider) {
DecoderResult decoderResult = ((DecoderResultProvider) msg).decoderResult();
if (decoderResult.isFailure()) {
sendDecodingFailures(decoderResult.cause(), msg, validateHeaders);
return;
}
if (msg instanceof DecoderResultProvider &&
handleDecodingFailures(((DecoderResultProvider) msg).decoderResult(), msg, validateHeaders)) {
return;
}

ctx.fireChannelRead(msg);
Expand Down Expand Up @@ -350,6 +348,14 @@ public void flush(ChannelHandlerContext ctx) {
}
}

boolean handleDecodingFailures(DecoderResult decoderResult, Object msg, boolean validateHeaders) {
if (decoderResult.isFailure()) {
sendDecodingFailures(decoderResult.cause(), msg, validateHeaders);
return true;
}
return false;
}

void sendDecodingFailures(Throwable t, Object msg, boolean validateHeaders) {
sendDecodingFailures(t, msg, null, null, validateHeaders);
}
Expand Down

0 comments on commit deea698

Please sign in to comment.