@@ -29,6 +29,7 @@ public class Netty4HttpHeaderValidator extends ChannelDuplexHandler {
2929 private final ThreadContext threadContext ;
3030 private boolean droppingContent ;
3131 private boolean validatingRequest ;
32+ private boolean readRequested ;
3233
3334 public Netty4HttpHeaderValidator (HttpValidator validator , ThreadContext threadContext ) {
3435 this .validator = validator ;
@@ -47,6 +48,7 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception
4748 } else if (msg instanceof HttpContent content ) {
4849 if (droppingContent ) {
4950 content .release ();
51+ ctx .read ();
5052 } else {
5153 assert validatingRequest == false : "unexpected content before validation completed" ;
5254 ctx .fireChannelRead (content );
@@ -60,7 +62,10 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception
6062 public void read (ChannelHandlerContext ctx ) throws Exception {
6163 // until validation is completed we can ignore read calls,
6264 // once validation is finished HttpRequest will be fired and downstream can read from there
63- if (validatingRequest == false ) {
65+ if (validatingRequest ) {
66+ readRequested = true ;
67+ } else {
68+ readRequested = false ;
6469 ctx .read ();
6570 }
6671 }
@@ -108,6 +113,10 @@ void handleValidationResult(ChannelHandlerContext ctx, HttpRequest request, @Nul
108113 }
109114 validatingRequest = false ;
110115 ctx .fireChannelRead (request );
116+ if (readRequested ) {
117+ readRequested = false ;
118+ ctx .channel ().eventLoop ().execute (ctx ::read );
119+ }
111120 });
112121 }
113122
0 commit comments