Skip to content

Commit

Permalink
Even more downstream respect
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim-Brooks committed Sep 6, 2024
1 parent 280cddc commit c0767ee
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception
pending.add(ReferenceCountUtil.retain(httpObject));
requestStart(ctx);
assert state == QUEUEING_DATA;
ctx.channel().config().setAutoRead(false);
assert ctx.channel().config().isAutoRead() == false;
break;
case QUEUEING_DATA:
pending.add(ReferenceCountUtil.retain(httpObject));
Expand Down Expand Up @@ -105,6 +105,7 @@ private void requestStart(ChannelHandlerContext ctx) {
}

state = QUEUEING_DATA;
ctx.channel().config().setAutoRead(false);

if (httpRequest == null) {
// this looks like a malformed request and will forward without validation
Expand Down Expand Up @@ -150,6 +151,7 @@ private void forwardFullRequest(ChannelHandlerContext ctx) {
assert ctx.channel().config().isAutoRead() == false;
assert state == QUEUEING_DATA;

ctx.channel().config().setAutoRead(true);
boolean fullRequestForwarded = forwardData(ctx, pending);

assert fullRequestForwarded || pending.isEmpty();
Expand All @@ -161,7 +163,6 @@ private void forwardFullRequest(ChannelHandlerContext ctx) {
}

assert state == WAITING_TO_START || state == QUEUEING_DATA || state == FORWARDING_DATA_UNTIL_NEXT_REQUEST;
ctx.channel().config().setAutoRead(state != QUEUEING_DATA);
}

private void forwardRequestWithDecoderExceptionAndNoContent(ChannelHandlerContext ctx, Exception e) {
Expand All @@ -177,6 +178,8 @@ private void forwardRequestWithDecoderExceptionAndNoContent(ChannelHandlerContex
messageToForward = toReplace.replace(Unpooled.EMPTY_BUFFER);
}
messageToForward.setDecoderResult(DecoderResult.failure(e));

ctx.channel().config().setAutoRead(true);
ctx.fireChannelRead(messageToForward);

assert fullRequestDropped || pending.isEmpty();
Expand All @@ -188,7 +191,6 @@ private void forwardRequestWithDecoderExceptionAndNoContent(ChannelHandlerContex
}

assert state == WAITING_TO_START || state == QUEUEING_DATA || state == DROPPING_DATA_UNTIL_NEXT_REQUEST;
ctx.channel().config().setAutoRead(state != QUEUEING_DATA);
}

@Override
Expand Down

0 comments on commit c0767ee

Please sign in to comment.