diff --git a/example/src/main/java/io/netty/example/http2/helloworld/frame/server/HelloWorldHttp2Handler.java b/example/src/main/java/io/netty/example/http2/helloworld/frame/server/HelloWorldHttp2Handler.java index b7d1e383f0..2ca8c869de 100644 --- a/example/src/main/java/io/netty/example/http2/helloworld/frame/server/HelloWorldHttp2Handler.java +++ b/example/src/main/java/io/netty/example/http2/helloworld/frame/server/HelloWorldHttp2Handler.java @@ -61,10 +61,15 @@ public class HelloWorldHttp2Handler extends ChannelDuplexHandler { } } + @Override + public void channelReadComplete(ChannelHandlerContext ctx) throws Exception { + ctx.flush(); + } + /** * If receive a frame with end-of-stream set, send a pre-canned response. */ - public void onDataRead(ChannelHandlerContext ctx, Http2DataFrame data) throws Exception { + private static void onDataRead(ChannelHandlerContext ctx, Http2DataFrame data) throws Exception { int consumed = data.padding() + data.content().readableBytes(); int streamId = data.streamId(); @@ -82,7 +87,7 @@ public class HelloWorldHttp2Handler extends ChannelDuplexHandler { /** * If receive a frame with end-of-stream set, send a pre-canned response. */ - public void onHeadersRead(ChannelHandlerContext ctx, Http2HeadersFrame headers) + private static void onHeadersRead(ChannelHandlerContext ctx, Http2HeadersFrame headers) throws Exception { if (headers.isEndStream()) { ByteBuf content = ctx.alloc().buffer(); @@ -99,6 +104,6 @@ public class HelloWorldHttp2Handler extends ChannelDuplexHandler { // Send a frame for the response status Http2Headers headers = new DefaultHttp2Headers().status(OK.codeAsText()); ctx.write(new DefaultHttp2HeadersFrame(headers).streamId(streamId)); - ctx.writeAndFlush(new DefaultHttp2DataFrame(payload, true).streamId(streamId)); + ctx.write(new DefaultHttp2DataFrame(payload, true).streamId(streamId)); } } diff --git a/example/src/main/java/io/netty/example/http2/helloworld/multiplex/server/HelloWorldHttp2Handler.java b/example/src/main/java/io/netty/example/http2/helloworld/multiplex/server/HelloWorldHttp2Handler.java index 3c82a03129..7e5748f725 100644 --- a/example/src/main/java/io/netty/example/http2/helloworld/multiplex/server/HelloWorldHttp2Handler.java +++ b/example/src/main/java/io/netty/example/http2/helloworld/multiplex/server/HelloWorldHttp2Handler.java @@ -60,10 +60,15 @@ public class HelloWorldHttp2Handler extends ChannelDuplexHandler { } } + @Override + public void channelReadComplete(ChannelHandlerContext ctx) throws Exception { + ctx.flush(); + } + /** * If receive a frame with end-of-stream set, send a pre-canned response. */ - public void onDataRead(ChannelHandlerContext ctx, Http2DataFrame data) throws Exception { + private static void onDataRead(ChannelHandlerContext ctx, Http2DataFrame data) throws Exception { if (data.isEndStream()) { sendResponse(ctx, data.content()); } else { @@ -75,7 +80,7 @@ public class HelloWorldHttp2Handler extends ChannelDuplexHandler { /** * If receive a frame with end-of-stream set, send a pre-canned response. */ - public void onHeadersRead(ChannelHandlerContext ctx, Http2HeadersFrame headers) + private static void onHeadersRead(ChannelHandlerContext ctx, Http2HeadersFrame headers) throws Exception { if (headers.isEndStream()) { ByteBuf content = ctx.alloc().buffer(); @@ -92,6 +97,6 @@ public class HelloWorldHttp2Handler extends ChannelDuplexHandler { // Send a frame for the response status Http2Headers headers = new DefaultHttp2Headers().status(OK.codeAsText()); ctx.write(new DefaultHttp2HeadersFrame(headers)); - ctx.writeAndFlush(new DefaultHttp2DataFrame(payload, true)); + ctx.write(new DefaultHttp2DataFrame(payload, true)); } } diff --git a/example/src/main/java/io/netty/example/http2/helloworld/server/HelloWorldHttp1Handler.java b/example/src/main/java/io/netty/example/http2/helloworld/server/HelloWorldHttp1Handler.java index 7277fe6ea9..f5cfbf1fa7 100644 --- a/example/src/main/java/io/netty/example/http2/helloworld/server/HelloWorldHttp1Handler.java +++ b/example/src/main/java/io/netty/example/http2/helloworld/server/HelloWorldHttp1Handler.java @@ -60,13 +60,18 @@ public class HelloWorldHttp1Handler extends SimpleChannelInboundHandler