Skip to content

Commit da22ff9

Browse files
authored
Merge pull request #31203 from isaacrivriv/partial-incomingBodyBufferSize-netty
Partial incoming body buffer size netty
2 parents cc58920 + ccc15d3 commit da22ff9

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

dev/com.ibm.ws.transport.http/src/com/ibm/ws/http/netty/pipeline/HttpPipelineInitializer.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import io.netty.channel.ChannelInboundHandlerAdapter;
4242
import io.netty.channel.ChannelOption;
4343
import io.netty.channel.ChannelPipeline;
44+
import io.netty.channel.FixedRecvByteBufAllocator;
4445
import io.netty.channel.RecvByteBufAllocator;
4546
import io.netty.channel.SimpleChannelInboundHandler;
4647
import io.netty.channel.ChannelHandler.Sharable;
@@ -116,7 +117,7 @@ protected void initChannel(Channel channel) throws Exception {
116117
channel.attr(NettyHttpConstants.IS_OUTBOUND_KEY).set(false);
117118
channel.attr(NettyHttpConstants.ENDPOINT_PID).set(chain.getEndpointPID());
118119

119-
RecvByteBufAllocator channelAllocator = channel.config().getRecvByteBufAllocator();
120+
FixedRecvByteBufAllocator channelAllocator = new FixedRecvByteBufAllocator(httpConfig.getIncomingBodyBufferSize());
120121
LoggingRecvByteBufAllocator loggingAllocator = new LoggingRecvByteBufAllocator(channelAllocator);
121122
channel.config().setRecvByteBufAllocator(loggingAllocator);
122123

dev/com.ibm.ws.transport.http/src/com/ibm/ws/http/netty/pipeline/http2/LibertyUpgradeCodec.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ public Collection<CharSequence> requiredUpgradeHeaders() {
172172

173173
HttpToHttp2ConnectionHandler buildHttp2ConnectionHandler(HttpChannelConfig httpConfig, Channel channel) {
174174
DefaultHttp2Connection connection = new DefaultHttp2Connection(true);
175-
int maxContentlength = (int) httpConfig.getMessageSizeLimit();
175+
// Netty accepts integer for max length so we would need to adapt for this
176+
int maxContentlength = httpConfig.getMessageSizeLimit() >= Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) httpConfig.getMessageSizeLimit();
176177
InboundHttp2ToHttpAdapterBuilder builder = new InboundHttp2ToHttpAdapterBuilder(connection).propagateSettings(false).validateHttpHeaders(false);
177178
if (maxContentlength > 0)
178179
builder.maxContentLength(maxContentlength);

0 commit comments

Comments
 (0)