diff --git a/client/src/main/java/org/asynchttpclient/AsyncHttpClientConfig.java b/client/src/main/java/org/asynchttpclient/AsyncHttpClientConfig.java index 484cd0029..5c6de2f25 100644 --- a/client/src/main/java/org/asynchttpclient/AsyncHttpClientConfig.java +++ b/client/src/main/java/org/asynchttpclient/AsyncHttpClientConfig.java @@ -290,6 +290,10 @@ public interface AsyncHttpClientConfig { int getHttpClientCodecInitialBufferSize(); + boolean getHttpClientCodecParseHttpAfterConnectRequest(); + + boolean getHttpClientCodecAllowDuplicateContentLengths(); + boolean isDisableZeroCopy(); int getHandshakeTimeout(); diff --git a/client/src/main/java/org/asynchttpclient/DefaultAsyncHttpClientConfig.java b/client/src/main/java/org/asynchttpclient/DefaultAsyncHttpClientConfig.java index 0357592bd..b53d31676 100644 --- a/client/src/main/java/org/asynchttpclient/DefaultAsyncHttpClientConfig.java +++ b/client/src/main/java/org/asynchttpclient/DefaultAsyncHttpClientConfig.java @@ -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; @@ -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, Object> channelOptions; private final @Nullable EventLoopGroup eventLoopGroup; @@ -275,6 +279,8 @@ private DefaultAsyncHttpClientConfig(// http int httpClientCodecMaxHeaderSize, int httpClientCodecMaxChunkSize, int httpClientCodecInitialBufferSize, + boolean httpClientCodecParseHttpAfterConnectRequest, + boolean httpClientCodecAllowDuplicateContentLengths, int chunkedFileChunkSize, int webSocketMaxBufferSize, int webSocketMaxFrameSize, @@ -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; @@ -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; @@ -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(); @@ -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; @@ -1476,6 +1507,8 @@ public DefaultAsyncHttpClientConfig build() { httpClientCodecMaxHeaderSize, httpClientCodecMaxChunkSize, httpClientCodecInitialBufferSize, + httpClientCodecParseHttpAfterConnectRequest, + httpClientCodecAllowDuplicateContentLengths, chunkedFileChunkSize, webSocketMaxBufferSize, webSocketMaxFrameSize, diff --git a/client/src/main/java/org/asynchttpclient/config/AsyncHttpClientConfigDefaults.java b/client/src/main/java/org/asynchttpclient/config/AsyncHttpClientConfigDefaults.java index 3d4cb6106..a950112da 100644 --- a/client/src/main/java/org/asynchttpclient/config/AsyncHttpClientConfigDefaults.java +++ b/client/src/main/java/org/asynchttpclient/config/AsyncHttpClientConfigDefaults.java @@ -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"; @@ -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); } diff --git a/client/src/main/java/org/asynchttpclient/netty/channel/ChannelManager.java b/client/src/main/java/org/asynchttpclient/netty/channel/ChannelManager.java index fe85734c7..a37dd0059 100755 --- a/client/src/main/java/org/asynchttpclient/netty/channel/ChannelManager.java +++ b/client/src/main/java/org/asynchttpclient/netty/channel/ChannelManager.java @@ -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) { diff --git a/client/src/main/resources/org/asynchttpclient/config/ahc-default.properties b/client/src/main/resources/org/asynchttpclient/config/ahc-default.properties index 6450221b0..73b5c75d3 100644 --- a/client/src/main/resources/org/asynchttpclient/config/ahc-default.properties +++ b/client/src/main/resources/org/asynchttpclient/config/ahc-default.properties @@ -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