Skip to content

Commit 4922a57

Browse files
authored
Convert ByteBuf directly to Http2DataFrame instead of wrapping in DefaultHttpContent (#4045)
With this change, Http2StreamFrameToHttpObjectCodec will be skipped as no additional handling is needed. Signed-off-by: Violeta Georgieva <696661+violetagg@users.noreply.github.com>
1 parent cb2823b commit 4922a57

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

reactor-netty-http/src/main/java/reactor/netty/http/client/Http2StreamBridgeClientHandler.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020-2022 VMware, Inc. or its affiliates, All Rights Reserved.
2+
* Copyright (c) 2020-2025 VMware, Inc. or its affiliates, All Rights Reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@
2020
import io.netty.channel.ChannelHandler;
2121
import io.netty.channel.ChannelHandlerContext;
2222
import io.netty.channel.ChannelPromise;
23-
import io.netty.handler.codec.http.DefaultHttpContent;
23+
import io.netty.handler.codec.http2.DefaultHttp2DataFrame;
2424
import io.netty.handler.codec.http2.Http2StreamFrameToHttpObjectCodec;
2525

2626
/**
@@ -44,7 +44,8 @@ public void channelActive(ChannelHandlerContext ctx) {
4444
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) {
4545
if (msg instanceof ByteBuf) {
4646
//"FutureReturnValueIgnored" this is deliberate
47-
ctx.write(new DefaultHttpContent((ByteBuf) msg), promise);
47+
//This will skip Http2StreamFrameToHttpObjectCodec as there is no need of any extra handling
48+
ctx.write(new DefaultHttp2DataFrame((ByteBuf) msg, false), promise);
4849
}
4950
else {
5051
//"FutureReturnValueIgnored" this is deliberate

reactor-netty-http/src/main/java/reactor/netty/http/server/Http2StreamBridgeServerHandler.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import io.netty.channel.ChannelPromise;
2929
import io.netty.handler.codec.DecoderResult;
3030
import io.netty.handler.codec.http.DefaultFullHttpResponse;
31-
import io.netty.handler.codec.http.DefaultHttpContent;
3231
import io.netty.handler.codec.http.DefaultHttpResponse;
3332
import io.netty.handler.codec.http.DefaultLastHttpContent;
3433
import io.netty.handler.codec.http.HttpObject;
@@ -39,6 +38,7 @@
3938
import io.netty.handler.codec.http.LastHttpContent;
4039
import io.netty.handler.codec.http.cookie.ServerCookieDecoder;
4140
import io.netty.handler.codec.http.cookie.ServerCookieEncoder;
41+
import io.netty.handler.codec.http2.DefaultHttp2DataFrame;
4242
import io.netty.handler.codec.http2.Http2StreamFrameToHttpObjectCodec;
4343
import io.netty.handler.ssl.SslHandler;
4444
import io.netty.util.ReferenceCountUtil;
@@ -224,7 +224,8 @@ else if (msg instanceof ByteBuf) {
224224
}
225225

226226
//"FutureReturnValueIgnored" this is deliberate
227-
ctx.write(new DefaultHttpContent((ByteBuf) msg), promise);
227+
//This will skip Http2StreamFrameToHttpObjectCodec as there is no need of any extra handling
228+
ctx.write(new DefaultHttp2DataFrame((ByteBuf) msg, false), promise);
228229
}
229230
else if (msg instanceof HttpResponse && HttpResponseStatus.CONTINUE.code() == ((HttpResponse) msg).status().code()) {
230231
//"FutureReturnValueIgnored" this is deliberate

0 commit comments

Comments
 (0)