Skip to content

Commit

Permalink
Remove the usage of deprecated API
Browse files Browse the repository at this point in the history
  • Loading branch information
violetagg committed Mar 8, 2024
1 parent 83ee197 commit 3efc381
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import io.netty.handler.codec.http.HttpClientCodec;
import io.netty.handler.codec.http.HttpClientUpgradeHandler;
import io.netty.handler.codec.http.HttpContentDecompressor;
import io.netty.handler.codec.http.HttpDecoderConfig;
import io.netty.handler.codec.http.HttpHeaders;
import io.netty.handler.codec.http.HttpMethod;
import io.netty.handler.codec.http.HttpResponse;
Expand Down Expand Up @@ -615,16 +616,15 @@ static void configureHttp11OrH2CleartextPipeline(
ChannelOperations.OnSetup opsFactory,
SocketAddress remoteAddress,
@Nullable Function<String, String> uriTagValue) {
HttpDecoderConfig decoderConfig = new HttpDecoderConfig();
decoderConfig.setMaxInitialLineLength(decoder.maxInitialLineLength())
.setMaxHeaderSize(decoder.maxHeaderSize())
.setMaxChunkSize(decoder.maxChunkSize())
.setValidateHeaders(decoder.validateHeaders())
.setInitialBufferSize(decoder.initialBufferSize())
.setAllowDuplicateContentLengths(decoder.allowDuplicateContentLengths());
HttpClientCodec httpClientCodec =
new HttpClientCodec(
decoder.maxInitialLineLength(),
decoder.maxHeaderSize(),
decoder.maxChunkSize(),
decoder.failOnMissingResponse,
decoder.validateHeaders(),
decoder.initialBufferSize(),
decoder.parseHttpAfterConnectRequest,
decoder.allowDuplicateContentLengths());
new HttpClientCodec(decoderConfig, decoder.failOnMissingResponse, decoder.parseHttpAfterConnectRequest);

Http2FrameCodecBuilder http2FrameCodecBuilder =
Http2FrameCodecBuilder.forClient()
Expand Down Expand Up @@ -669,17 +669,16 @@ static void configureHttp11Pipeline(ChannelPipeline p,
@Nullable ChannelMetricsRecorder metricsRecorder,
SocketAddress remoteAddress,
@Nullable Function<String, String> uriTagValue) {
HttpDecoderConfig decoderConfig = new HttpDecoderConfig();
decoderConfig.setMaxInitialLineLength(decoder.maxInitialLineLength())
.setMaxHeaderSize(decoder.maxHeaderSize())
.setMaxChunkSize(decoder.maxChunkSize())
.setValidateHeaders(decoder.validateHeaders())
.setInitialBufferSize(decoder.initialBufferSize())
.setAllowDuplicateContentLengths(decoder.allowDuplicateContentLengths());
p.addBefore(NettyPipeline.ReactiveBridge,
NettyPipeline.HttpCodec,
new HttpClientCodec(
decoder.maxInitialLineLength(),
decoder.maxHeaderSize(),
decoder.maxChunkSize(),
decoder.failOnMissingResponse,
decoder.validateHeaders(),
decoder.initialBufferSize(),
decoder.parseHttpAfterConnectRequest,
decoder.allowDuplicateContentLengths()));
new HttpClientCodec(decoderConfig, decoder.failOnMissingResponse, decoder.parseHttpAfterConnectRequest));

if (acceptGzip) {
p.addAfter(NettyPipeline.HttpCodec, NettyPipeline.HttpDecompressor, new HttpContentDecompressor());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023 VMware, Inc. or its affiliates, All Rights Reserved.
* Copyright (c) 2020-2024 VMware, Inc. or its affiliates, All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -24,6 +24,7 @@
import io.netty.channel.ChannelPipeline;
import io.netty.channel.ChannelPromise;
import io.netty.handler.codec.haproxy.HAProxyMessageDecoder;
import io.netty.handler.codec.http.HttpDecoderConfig;
import io.netty.handler.codec.http.HttpHeaderNames;
import io.netty.handler.codec.http.HttpRequest;
import io.netty.handler.codec.http.HttpServerCodec;
Expand Down Expand Up @@ -588,10 +589,15 @@ static void configureHttp11OrH2CleartextPipeline(ChannelPipeline p,
int minCompressionSize,
ChannelOperations.OnSetup opsFactory,
@Nullable Function<String, String> uriTagValue) {
HttpDecoderConfig decoderConfig = new HttpDecoderConfig();
decoderConfig.setMaxInitialLineLength(decoder.maxInitialLineLength())
.setMaxHeaderSize(decoder.maxHeaderSize())
.setMaxChunkSize(decoder.maxChunkSize())
.setValidateHeaders(decoder.validateHeaders())
.setInitialBufferSize(decoder.initialBufferSize())
.setAllowDuplicateContentLengths(decoder.allowDuplicateContentLengths());
HttpServerCodec httpServerCodec =
new HttpServerCodec(decoder.maxInitialLineLength(), decoder.maxHeaderSize(),
decoder.maxChunkSize(), decoder.validateHeaders(), decoder.initialBufferSize(),
decoder.allowDuplicateContentLengths());
new HttpServerCodec(decoderConfig);

Http11OrH2CleartextCodec upgrader = new Http11OrH2CleartextCodec(accessLogEnabled, accessLog, compressPredicate,
cookieDecoder, cookieEncoder, p.get(NettyPipeline.LoggingHandler) != null, enableGracefulShutdown, formDecoderProvider,
Expand Down Expand Up @@ -655,11 +661,16 @@ static void configureHttp11Pipeline(ChannelPipeline p,
@Nullable ChannelMetricsRecorder metricsRecorder,
int minCompressionSize,
@Nullable Function<String, String> uriTagValue) {
HttpDecoderConfig decoderConfig = new HttpDecoderConfig();
decoderConfig.setMaxInitialLineLength(decoder.maxInitialLineLength())
.setMaxHeaderSize(decoder.maxHeaderSize())
.setMaxChunkSize(decoder.maxChunkSize())
.setValidateHeaders(decoder.validateHeaders())
.setInitialBufferSize(decoder.initialBufferSize())
.setAllowDuplicateContentLengths(decoder.allowDuplicateContentLengths());
p.addBefore(NettyPipeline.ReactiveBridge,
NettyPipeline.HttpCodec,
new HttpServerCodec(decoder.maxInitialLineLength(), decoder.maxHeaderSize(),
decoder.maxChunkSize(), decoder.validateHeaders(), decoder.initialBufferSize(),
decoder.allowDuplicateContentLengths()))
new HttpServerCodec(decoderConfig))
.addBefore(NettyPipeline.ReactiveBridge,
NettyPipeline.HttpTrafficHandler,
new HttpTrafficHandler(compressPredicate, cookieDecoder, cookieEncoder, formDecoderProvider,
Expand Down

0 comments on commit 3efc381

Please sign in to comment.