Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add config for allowDuplicateContentLengths #1890

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,10 @@ public interface AsyncHttpClientConfig {

int getHttpClientCodecInitialBufferSize();

boolean getHttpClientCodecParseHttpAfterConnectRequest();

boolean getHttpClientCodecAllowDuplicateContentLengths();

boolean isDisableZeroCopy();

int getHandshakeTimeout();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@
import static org.asynchttpclient.config.AsyncHttpClientConfigDefaults.defaultHashedWheelTimerSize;
import static org.asynchttpclient.config.AsyncHttpClientConfigDefaults.defaultHashedWheelTimerTickDuration;
import static org.asynchttpclient.config.AsyncHttpClientConfigDefaults.defaultHttpClientCodecInitialBufferSize;
import static org.asynchttpclient.config.AsyncHttpClientConfigDefaults.defaultHttpClientCodecParseHttpAfterConnectRequest;
import static org.asynchttpclient.config.AsyncHttpClientConfigDefaults.defaultHttpClientCodecAllowDuplicateContentLengths;
import static org.asynchttpclient.config.AsyncHttpClientConfigDefaults.defaultHttpClientCodecMaxChunkSize;
import static org.asynchttpclient.config.AsyncHttpClientConfigDefaults.defaultHttpClientCodecMaxHeaderSize;
import static org.asynchttpclient.config.AsyncHttpClientConfigDefaults.defaultHttpClientCodecMaxInitialLineLength;
Expand Down Expand Up @@ -181,6 +183,8 @@ public class DefaultAsyncHttpClientConfig implements AsyncHttpClientConfig {
private final int httpClientCodecMaxHeaderSize;
private final int httpClientCodecMaxChunkSize;
private final int httpClientCodecInitialBufferSize;
private final boolean httpClientCodecParseHttpAfterConnectRequest;
private final boolean httpClientCodecAllowDuplicateContentLengths;
private final int chunkedFileChunkSize;
private final Map<ChannelOption<Object>, Object> channelOptions;
private final @Nullable EventLoopGroup eventLoopGroup;
Expand Down Expand Up @@ -275,6 +279,8 @@ private DefaultAsyncHttpClientConfig(// http
int httpClientCodecMaxHeaderSize,
int httpClientCodecMaxChunkSize,
int httpClientCodecInitialBufferSize,
boolean httpClientCodecParseHttpAfterConnectRequest,
boolean httpClientCodecAllowDuplicateContentLengths,
int chunkedFileChunkSize,
int webSocketMaxBufferSize,
int webSocketMaxFrameSize,
Expand Down Expand Up @@ -369,6 +375,8 @@ private DefaultAsyncHttpClientConfig(// http
this.httpClientCodecMaxHeaderSize = httpClientCodecMaxHeaderSize;
this.httpClientCodecMaxChunkSize = httpClientCodecMaxChunkSize;
this.httpClientCodecInitialBufferSize = httpClientCodecInitialBufferSize;
this.httpClientCodecParseHttpAfterConnectRequest = httpClientCodecParseHttpAfterConnectRequest;
this.httpClientCodecAllowDuplicateContentLengths = httpClientCodecAllowDuplicateContentLengths;
this.chunkedFileChunkSize = chunkedFileChunkSize;
this.channelOptions = channelOptions;
this.eventLoopGroup = eventLoopGroup;
Expand Down Expand Up @@ -704,6 +712,17 @@ public int getHttpClientCodecInitialBufferSize() {
return httpClientCodecInitialBufferSize;
}

@Override
public boolean getHttpClientCodecParseHttpAfterConnectRequest() {
return httpClientCodecParseHttpAfterConnectRequest;
}

@Override
public boolean getHttpClientCodecAllowDuplicateContentLengths() {
return httpClientCodecAllowDuplicateContentLengths;
}


@Override
public int getChunkedFileChunkSize() {
return chunkedFileChunkSize;
Expand Down Expand Up @@ -857,6 +876,8 @@ public static class Builder {
private int httpClientCodecMaxHeaderSize = defaultHttpClientCodecMaxHeaderSize();
private int httpClientCodecMaxChunkSize = defaultHttpClientCodecMaxChunkSize();
private int httpClientCodecInitialBufferSize = defaultHttpClientCodecInitialBufferSize();
private boolean httpClientCodecParseHttpAfterConnectRequest = defaultHttpClientCodecParseHttpAfterConnectRequest();
private boolean httpClientCodecAllowDuplicateContentLengths = defaultHttpClientCodecAllowDuplicateContentLengths();
private int chunkedFileChunkSize = defaultChunkedFileChunkSize();
private boolean useNativeTransport = defaultUseNativeTransport();
private boolean useOnlyEpollNativeTransport = defaultUseOnlyEpollNativeTransport();
Expand Down Expand Up @@ -1328,6 +1349,16 @@ public Builder setHttpClientCodecInitialBufferSize(int httpClientCodecInitialBuf
return this;
}

public Builder setHttpClientCodecParseHttpAfterConnectRequest(boolean httpClientCodecParseHttpAfterConnectRequest) {
this.httpClientCodecParseHttpAfterConnectRequest = httpClientCodecParseHttpAfterConnectRequest;
return this;
}

public Builder setHttpClientCodecAllowDuplicateContentLengths(boolean httpClientCodecAllowDuplicateContentLengths) {
this.httpClientCodecAllowDuplicateContentLengths = httpClientCodecAllowDuplicateContentLengths;
return this;
}

public Builder setChunkedFileChunkSize(int chunkedFileChunkSize) {
this.chunkedFileChunkSize = chunkedFileChunkSize;
return this;
Expand Down Expand Up @@ -1476,6 +1507,8 @@ public DefaultAsyncHttpClientConfig build() {
httpClientCodecMaxHeaderSize,
httpClientCodecMaxChunkSize,
httpClientCodecInitialBufferSize,
httpClientCodecParseHttpAfterConnectRequest,
httpClientCodecAllowDuplicateContentLengths,
chunkedFileChunkSize,
webSocketMaxBufferSize,
webSocketMaxFrameSize,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ public final class AsyncHttpClientConfigDefaults {
public static final String HTTP_CLIENT_CODEC_MAX_HEADER_SIZE_CONFIG = "httpClientCodecMaxHeaderSize";
public static final String HTTP_CLIENT_CODEC_MAX_CHUNK_SIZE_CONFIG = "httpClientCodecMaxChunkSize";
public static final String HTTP_CLIENT_CODEC_INITIAL_BUFFER_SIZE_CONFIG = "httpClientCodecInitialBufferSize";
public static final String HTTP_CLIENT_CODEC_PARSE_HTTP_AFTER_CONNECT_REQUEST = "httpClientCodecParseHttpAfterConnectRequest";
public static final String HTTP_CLIENT_CODEC_ALLOW_DUPLICATE_CONTENT_LENGTHS = "httpClientCodecAllowDuplicateContentLengths";
public static final String DISABLE_ZERO_COPY_CONFIG = "disableZeroCopy";
public static final String HANDSHAKE_TIMEOUT_CONFIG = "handshakeTimeout";
public static final String CHUNKED_FILE_CHUNK_SIZE_CONFIG = "chunkedFileChunkSize";
Expand Down Expand Up @@ -271,6 +273,14 @@ public static int defaultHttpClientCodecInitialBufferSize() {
return AsyncHttpClientConfigHelper.getAsyncHttpClientConfig().getInt(ASYNC_CLIENT_CONFIG_ROOT + HTTP_CLIENT_CODEC_INITIAL_BUFFER_SIZE_CONFIG);
}

public static boolean defaultHttpClientCodecParseHttpAfterConnectRequest() {
return AsyncHttpClientConfigHelper.getAsyncHttpClientConfig().getBoolean(ASYNC_CLIENT_CONFIG_ROOT + HTTP_CLIENT_CODEC_PARSE_HTTP_AFTER_CONNECT_REQUEST);
}

public static boolean defaultHttpClientCodecAllowDuplicateContentLengths() {
return AsyncHttpClientConfigHelper.getAsyncHttpClientConfig().getBoolean(ASYNC_CLIENT_CONFIG_ROOT + HTTP_CLIENT_CODEC_ALLOW_DUPLICATE_CONTENT_LENGTHS);
}

public static boolean defaultDisableZeroCopy() {
return AsyncHttpClientConfigHelper.getAsyncHttpClientConfig().getBoolean(ASYNC_CLIENT_CONFIG_ROOT + DISABLE_ZERO_COPY_CONFIG);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,9 @@ private HttpClientCodec newHttpClientCodec() {
config.getHttpClientCodecMaxChunkSize(),
false,
config.isValidateResponseHeaders(),
config.getHttpClientCodecInitialBufferSize());
config.getHttpClientCodecInitialBufferSize(),
config.getHttpClientCodecParseHttpAfterConnectRequest(),
config.getHttpClientCodecAllowDuplicateContentLengths());
}

private SslHandler createSslHandler(String peerHost, int peerPort) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ org.asynchttpclient.httpClientCodecMaxInitialLineLength=4096
org.asynchttpclient.httpClientCodecMaxHeaderSize=8192
org.asynchttpclient.httpClientCodecMaxChunkSize=8192
org.asynchttpclient.httpClientCodecInitialBufferSize=128
org.asynchttpclient.httpClientCodecParseHttpAfterConnectRequest=false
org.asynchttpclient.httpClientCodecAllowDuplicateContentLengths=false
org.asynchttpclient.disableZeroCopy=false
org.asynchttpclient.handshakeTimeout=10000
org.asynchttpclient.chunkedFileChunkSize=8192
Expand Down