From fa4595cf853f2f55b6a4ffc9f653330f6a25688d Mon Sep 17 00:00:00 2001 From: kkewwei Date: Wed, 15 Jan 2025 23:25:55 +0800 Subject: [PATCH] Upgrade HttpCore5/HttpClient5 to support ExtendedSocketOption in HttpAsyncClient (#16757) * upgrade httpcore5/httpclient5 to support ExtendedSocketOption in HttpAsyncClient Signed-off-by: kkewwei Signed-off-by: kkewwei * Use the Upgrade flow by default Signed-off-by: Andriy Redko * Update Reactor Netty to 1.1.26.Final Signed-off-by: Andriy Redko * Add SETTING_H2C_MAX_CONTENT_LENGTH to configure h2cMaxContentLength for reactor-netty4 transport Signed-off-by: Andriy Redko * Update Apache HttpCore5 to 5.3.2 Signed-off-by: Andriy Redko --------- Signed-off-by: kkewwei Signed-off-by: kkewwei Signed-off-by: Andriy Redko Co-authored-by: Andriy Redko --- CHANGELOG-3.0.md | 1 + .../org/opensearch/bootstrap/test.policy | 11 +++++++++++ .../rest/licenses/httpclient5-5.3.1.jar.sha1 | 1 - .../rest/licenses/httpclient5-5.4.1.jar.sha1 | 1 + client/rest/licenses/httpcore5-5.2.5.jar.sha1 | 1 - client/rest/licenses/httpcore5-5.3.2.jar.sha1 | 1 + .../rest/licenses/httpcore5-h2-5.2.5.jar.sha1 | 1 - .../rest/licenses/httpcore5-h2-5.3.2.jar.sha1 | 1 + .../licenses/httpcore5-reactive-5.2.5.jar.sha1 | 1 - .../licenses/httpcore5-reactive-5.3.2.jar.sha1 | 1 + .../client/RestClientBuilderTests.java | 7 +++++++ .../client/RestClientSingleHostIntegTests.java | 10 +++++++++- .../documentation/RestClientDocumentation.java | 18 ++++++++++++++++++ .../licenses/httpclient5-5.3.1.jar.sha1 | 1 - .../licenses/httpclient5-5.4.1.jar.sha1 | 1 + .../sniffer/licenses/httpcore5-5.2.5.jar.sha1 | 1 - .../sniffer/licenses/httpcore5-5.3.2.jar.sha1 | 1 + gradle/libs.versions.toml | 6 +++--- .../reactor-netty-core-1.1.23.jar.sha1 | 1 - .../reactor-netty-core-1.1.26.jar.sha1 | 1 + .../reactor-netty-http-1.1.23.jar.sha1 | 1 - .../reactor-netty-http-1.1.26.jar.sha1 | 1 + .../reactor-netty-core-1.1.23.jar.sha1 | 1 - .../reactor-netty-core-1.1.26.jar.sha1 | 1 + .../reactor-netty-http-1.1.23.jar.sha1 | 1 - .../reactor-netty-http-1.1.26.jar.sha1 | 1 + .../ReactorNetty4HttpServerTransport.java | 17 +++++++++++++++++ .../transport/reactor/ReactorNetty4Plugin.java | 2 +- .../opensearch/bootstrap/test-framework.policy | 2 +- 29 files changed, 78 insertions(+), 16 deletions(-) create mode 100644 client/rest-high-level/src/test/resources/org/opensearch/bootstrap/test.policy delete mode 100644 client/rest/licenses/httpclient5-5.3.1.jar.sha1 create mode 100644 client/rest/licenses/httpclient5-5.4.1.jar.sha1 delete mode 100644 client/rest/licenses/httpcore5-5.2.5.jar.sha1 create mode 100644 client/rest/licenses/httpcore5-5.3.2.jar.sha1 delete mode 100644 client/rest/licenses/httpcore5-h2-5.2.5.jar.sha1 create mode 100644 client/rest/licenses/httpcore5-h2-5.3.2.jar.sha1 delete mode 100644 client/rest/licenses/httpcore5-reactive-5.2.5.jar.sha1 create mode 100644 client/rest/licenses/httpcore5-reactive-5.3.2.jar.sha1 delete mode 100644 client/sniffer/licenses/httpclient5-5.3.1.jar.sha1 create mode 100644 client/sniffer/licenses/httpclient5-5.4.1.jar.sha1 delete mode 100644 client/sniffer/licenses/httpcore5-5.2.5.jar.sha1 create mode 100644 client/sniffer/licenses/httpcore5-5.3.2.jar.sha1 delete mode 100644 plugins/repository-azure/licenses/reactor-netty-core-1.1.23.jar.sha1 create mode 100644 plugins/repository-azure/licenses/reactor-netty-core-1.1.26.jar.sha1 delete mode 100644 plugins/repository-azure/licenses/reactor-netty-http-1.1.23.jar.sha1 create mode 100644 plugins/repository-azure/licenses/reactor-netty-http-1.1.26.jar.sha1 delete mode 100644 plugins/transport-reactor-netty4/licenses/reactor-netty-core-1.1.23.jar.sha1 create mode 100644 plugins/transport-reactor-netty4/licenses/reactor-netty-core-1.1.26.jar.sha1 delete mode 100644 plugins/transport-reactor-netty4/licenses/reactor-netty-http-1.1.23.jar.sha1 create mode 100644 plugins/transport-reactor-netty4/licenses/reactor-netty-http-1.1.26.jar.sha1 diff --git a/CHANGELOG-3.0.md b/CHANGELOG-3.0.md index 48d978bede420..fddead96aaf45 100644 --- a/CHANGELOG-3.0.md +++ b/CHANGELOG-3.0.md @@ -15,6 +15,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Views, simplify data access and manipulation by providing a virtual layer over one or more indices ([#11957](https://github.com/opensearch-project/OpenSearch/pull/11957)) ### Dependencies +- Bump Apache HttpCore5/HttpClient5 dependencies from 5.2.5/5.3.1 to 5.3.1/5.4.1 to support ExtendedSocketOption in HttpAsyncClient ([#16757](https://github.com/opensearch-project/OpenSearch/pull/16757)) ### Changed - Changed locale provider from COMPAT to CLDR ([#14345](https://github.com/opensearch-project/OpenSearch/pull/14345)) diff --git a/client/rest-high-level/src/test/resources/org/opensearch/bootstrap/test.policy b/client/rest-high-level/src/test/resources/org/opensearch/bootstrap/test.policy new file mode 100644 index 0000000000000..2604c2492d8ab --- /dev/null +++ b/client/rest-high-level/src/test/resources/org/opensearch/bootstrap/test.policy @@ -0,0 +1,11 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +grant { + permission java.net.SocketPermission "*", "connect,resolve"; +}; diff --git a/client/rest/licenses/httpclient5-5.3.1.jar.sha1 b/client/rest/licenses/httpclient5-5.3.1.jar.sha1 deleted file mode 100644 index c8f32c1ec23a1..0000000000000 --- a/client/rest/licenses/httpclient5-5.3.1.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -56b53c8f4bcdaada801d311cf2ff8a24d6d96883 \ No newline at end of file diff --git a/client/rest/licenses/httpclient5-5.4.1.jar.sha1 b/client/rest/licenses/httpclient5-5.4.1.jar.sha1 new file mode 100644 index 0000000000000..40156e9a42620 --- /dev/null +++ b/client/rest/licenses/httpclient5-5.4.1.jar.sha1 @@ -0,0 +1 @@ +ce913081e592ee8eeee35c4e577d7dce13cba7a4 \ No newline at end of file diff --git a/client/rest/licenses/httpcore5-5.2.5.jar.sha1 b/client/rest/licenses/httpcore5-5.2.5.jar.sha1 deleted file mode 100644 index ca97e8612ea39..0000000000000 --- a/client/rest/licenses/httpcore5-5.2.5.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -dab1e18842971a45ca8942491ce005ab86a028d7 \ No newline at end of file diff --git a/client/rest/licenses/httpcore5-5.3.2.jar.sha1 b/client/rest/licenses/httpcore5-5.3.2.jar.sha1 new file mode 100644 index 0000000000000..44c13325b5647 --- /dev/null +++ b/client/rest/licenses/httpcore5-5.3.2.jar.sha1 @@ -0,0 +1 @@ +35d387301d4a719972b15fbe863020da5f913c22 \ No newline at end of file diff --git a/client/rest/licenses/httpcore5-h2-5.2.5.jar.sha1 b/client/rest/licenses/httpcore5-h2-5.2.5.jar.sha1 deleted file mode 100644 index bb40fe65854f6..0000000000000 --- a/client/rest/licenses/httpcore5-h2-5.2.5.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -09425df4d1365cee86a8e031a036bdca4343da4b \ No newline at end of file diff --git a/client/rest/licenses/httpcore5-h2-5.3.2.jar.sha1 b/client/rest/licenses/httpcore5-h2-5.3.2.jar.sha1 new file mode 100644 index 0000000000000..67c92d8fea09c --- /dev/null +++ b/client/rest/licenses/httpcore5-h2-5.3.2.jar.sha1 @@ -0,0 +1 @@ +d908a946e9161511accdc739e443b1e0b0cbba82 \ No newline at end of file diff --git a/client/rest/licenses/httpcore5-reactive-5.2.5.jar.sha1 b/client/rest/licenses/httpcore5-reactive-5.2.5.jar.sha1 deleted file mode 100644 index ab9241fc93d45..0000000000000 --- a/client/rest/licenses/httpcore5-reactive-5.2.5.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -f68949965075b957c12b4c1ef89fd4bab2a0fdb1 \ No newline at end of file diff --git a/client/rest/licenses/httpcore5-reactive-5.3.2.jar.sha1 b/client/rest/licenses/httpcore5-reactive-5.3.2.jar.sha1 new file mode 100644 index 0000000000000..345d71cb206ae --- /dev/null +++ b/client/rest/licenses/httpcore5-reactive-5.3.2.jar.sha1 @@ -0,0 +1 @@ +9ee35ef1d3e40855695fc87ad2e31192d85c1e88 \ No newline at end of file diff --git a/client/rest/src/test/java/org/opensearch/client/RestClientBuilderTests.java b/client/rest/src/test/java/org/opensearch/client/RestClientBuilderTests.java index 7165174e688e1..c9ad10a476f74 100644 --- a/client/rest/src/test/java/org/opensearch/client/RestClientBuilderTests.java +++ b/client/rest/src/test/java/org/opensearch/client/RestClientBuilderTests.java @@ -37,6 +37,7 @@ import org.apache.hc.core5.http.Header; import org.apache.hc.core5.http.HttpHost; import org.apache.hc.core5.http.message.BasicHeader; +import org.apache.hc.core5.reactor.IOReactorConfig; import org.apache.hc.core5.util.Timeout; import java.io.IOException; @@ -143,6 +144,12 @@ public void testBuild() throws IOException { builder.setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() { @Override public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) { + IOReactorConfig.Builder iOReactorConfig = IOReactorConfig.custom(); + iOReactorConfig.setTcpKeepCount(randomIntBetween(4, 10)); + iOReactorConfig.setTcpKeepInterval(randomIntBetween(5, 10)); + iOReactorConfig.setTcpKeepIdle(randomIntBetween(100, 200)); + iOReactorConfig.setIoThreadCount(2); + httpClientBuilder.setIOReactorConfig(iOReactorConfig.build()); return httpClientBuilder; } }); diff --git a/client/rest/src/test/java/org/opensearch/client/RestClientSingleHostIntegTests.java b/client/rest/src/test/java/org/opensearch/client/RestClientSingleHostIntegTests.java index de04dd843b2db..84f6e7c8beb2e 100644 --- a/client/rest/src/test/java/org/opensearch/client/RestClientSingleHostIntegTests.java +++ b/client/rest/src/test/java/org/opensearch/client/RestClientSingleHostIntegTests.java @@ -382,6 +382,10 @@ public void testHeaders() throws Exception { if (method.equals("HEAD") == false) { standardHeaders.add("Content-length"); } + if (method.equals("HEAD") == true || method.equals("GET") == true || method.equals("OPTIONS") == true) { + standardHeaders.add("Upgrade"); + } + final Header[] requestHeaders = RestClientTestUtil.randomHeaders(getRandom(), "Header"); final int statusCode = randomStatusCode(getRandom()); Request request = new Request(method, "/" + statusCode); @@ -400,11 +404,15 @@ public void testHeaders() throws Exception { assertEquals(method, esResponse.getRequestLine().getMethod()); assertEquals(statusCode, esResponse.getStatusLine().getStatusCode()); assertEquals(pathPrefix + "/" + statusCode, esResponse.getRequestLine().getUri()); + assertHeaders(defaultHeaders, requestHeaders, esResponse.getHeaders(), standardHeaders); + final Set removedHeaders = new HashSet<>(); for (final Header responseHeader : esResponse.getHeaders()) { String name = responseHeader.getName(); - if (name.startsWith("Header") == false) { + // Some headers could be returned multiple times in response, like Connection fe. + if (name.startsWith("Header") == false && removedHeaders.contains(name) == false) { assertTrue("unknown header was returned " + name, standardHeaders.remove(name)); + removedHeaders.add(name); } } assertTrue("some expected standard headers weren't returned: " + standardHeaders, standardHeaders.isEmpty()); diff --git a/client/rest/src/test/java/org/opensearch/client/documentation/RestClientDocumentation.java b/client/rest/src/test/java/org/opensearch/client/documentation/RestClientDocumentation.java index 42c31864e0578..d9c82307cae8a 100644 --- a/client/rest/src/test/java/org/opensearch/client/documentation/RestClientDocumentation.java +++ b/client/rest/src/test/java/org/opensearch/client/documentation/RestClientDocumentation.java @@ -376,6 +376,24 @@ public HttpAsyncClientBuilder customizeHttpClient( }); //end::rest-client-config-threads } + { + //tag::rest-client-config-tcpKeepIdle/tcpKeepInterval/tcpKeepCount + RestClientBuilder builder = RestClient.builder( + new HttpHost("localhost", 9200)) + .setHttpClientConfigCallback(new HttpClientConfigCallback() { + @Override + public HttpAsyncClientBuilder customizeHttpClient( + HttpAsyncClientBuilder httpClientBuilder) { + return httpClientBuilder.setIOReactorConfig( + IOReactorConfig.custom() + .setTcpKeepIdle(200) + .setTcpKeepInterval(10) + .setTcpKeepCount(10) + .build()); + } + }); + //end::rest-client-config-tcpKeepIdle/tcpKeepInterval/tcpKeepCount + } { //tag::rest-client-config-basic-auth final BasicCredentialsProvider credentialsProvider = new BasicCredentialsProvider(); diff --git a/client/sniffer/licenses/httpclient5-5.3.1.jar.sha1 b/client/sniffer/licenses/httpclient5-5.3.1.jar.sha1 deleted file mode 100644 index c8f32c1ec23a1..0000000000000 --- a/client/sniffer/licenses/httpclient5-5.3.1.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -56b53c8f4bcdaada801d311cf2ff8a24d6d96883 \ No newline at end of file diff --git a/client/sniffer/licenses/httpclient5-5.4.1.jar.sha1 b/client/sniffer/licenses/httpclient5-5.4.1.jar.sha1 new file mode 100644 index 0000000000000..40156e9a42620 --- /dev/null +++ b/client/sniffer/licenses/httpclient5-5.4.1.jar.sha1 @@ -0,0 +1 @@ +ce913081e592ee8eeee35c4e577d7dce13cba7a4 \ No newline at end of file diff --git a/client/sniffer/licenses/httpcore5-5.2.5.jar.sha1 b/client/sniffer/licenses/httpcore5-5.2.5.jar.sha1 deleted file mode 100644 index ca97e8612ea39..0000000000000 --- a/client/sniffer/licenses/httpcore5-5.2.5.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -dab1e18842971a45ca8942491ce005ab86a028d7 \ No newline at end of file diff --git a/client/sniffer/licenses/httpcore5-5.3.2.jar.sha1 b/client/sniffer/licenses/httpcore5-5.3.2.jar.sha1 new file mode 100644 index 0000000000000..44c13325b5647 --- /dev/null +++ b/client/sniffer/licenses/httpcore5-5.3.2.jar.sha1 @@ -0,0 +1 @@ +35d387301d4a719972b15fbe863020da5f913c22 \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 1cd2f8d87e1d4..96f6178295f00 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -37,12 +37,12 @@ joda = "2.12.7" roaringbitmap = "1.3.0" # project reactor -reactor_netty = "1.1.23" +reactor_netty = "1.1.26" reactor = "3.5.20" # client dependencies -httpclient5 = "5.3.1" -httpcore5 = "5.2.5" +httpclient5 = "5.4.1" +httpcore5 = "5.3.2" httpclient = "4.5.14" httpcore = "4.4.16" httpasyncclient = "4.1.5" diff --git a/plugins/repository-azure/licenses/reactor-netty-core-1.1.23.jar.sha1 b/plugins/repository-azure/licenses/reactor-netty-core-1.1.23.jar.sha1 deleted file mode 100644 index 8f56bb5165fa3..0000000000000 --- a/plugins/repository-azure/licenses/reactor-netty-core-1.1.23.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -a7059b0c18ab7aa0fa9e08b48cb6a20b15c11478 \ No newline at end of file diff --git a/plugins/repository-azure/licenses/reactor-netty-core-1.1.26.jar.sha1 b/plugins/repository-azure/licenses/reactor-netty-core-1.1.26.jar.sha1 new file mode 100644 index 0000000000000..e64cc3645514f --- /dev/null +++ b/plugins/repository-azure/licenses/reactor-netty-core-1.1.26.jar.sha1 @@ -0,0 +1 @@ +05a8c6004161a4c1a9c0639b05387baab6efaa32 \ No newline at end of file diff --git a/plugins/repository-azure/licenses/reactor-netty-http-1.1.23.jar.sha1 b/plugins/repository-azure/licenses/reactor-netty-http-1.1.23.jar.sha1 deleted file mode 100644 index 5bb3136f99e93..0000000000000 --- a/plugins/repository-azure/licenses/reactor-netty-http-1.1.23.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -94b294fa90aee2e88ad4337251e278aaac21362c \ No newline at end of file diff --git a/plugins/repository-azure/licenses/reactor-netty-http-1.1.26.jar.sha1 b/plugins/repository-azure/licenses/reactor-netty-http-1.1.26.jar.sha1 new file mode 100644 index 0000000000000..035d2fb1c4c4c --- /dev/null +++ b/plugins/repository-azure/licenses/reactor-netty-http-1.1.26.jar.sha1 @@ -0,0 +1 @@ +41682e517e2808fc469d6b2b85fea48d0a7fe73b \ No newline at end of file diff --git a/plugins/transport-reactor-netty4/licenses/reactor-netty-core-1.1.23.jar.sha1 b/plugins/transport-reactor-netty4/licenses/reactor-netty-core-1.1.23.jar.sha1 deleted file mode 100644 index 8f56bb5165fa3..0000000000000 --- a/plugins/transport-reactor-netty4/licenses/reactor-netty-core-1.1.23.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -a7059b0c18ab7aa0fa9e08b48cb6a20b15c11478 \ No newline at end of file diff --git a/plugins/transport-reactor-netty4/licenses/reactor-netty-core-1.1.26.jar.sha1 b/plugins/transport-reactor-netty4/licenses/reactor-netty-core-1.1.26.jar.sha1 new file mode 100644 index 0000000000000..e64cc3645514f --- /dev/null +++ b/plugins/transport-reactor-netty4/licenses/reactor-netty-core-1.1.26.jar.sha1 @@ -0,0 +1 @@ +05a8c6004161a4c1a9c0639b05387baab6efaa32 \ No newline at end of file diff --git a/plugins/transport-reactor-netty4/licenses/reactor-netty-http-1.1.23.jar.sha1 b/plugins/transport-reactor-netty4/licenses/reactor-netty-http-1.1.23.jar.sha1 deleted file mode 100644 index 5bb3136f99e93..0000000000000 --- a/plugins/transport-reactor-netty4/licenses/reactor-netty-http-1.1.23.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -94b294fa90aee2e88ad4337251e278aaac21362c \ No newline at end of file diff --git a/plugins/transport-reactor-netty4/licenses/reactor-netty-http-1.1.26.jar.sha1 b/plugins/transport-reactor-netty4/licenses/reactor-netty-http-1.1.26.jar.sha1 new file mode 100644 index 0000000000000..035d2fb1c4c4c --- /dev/null +++ b/plugins/transport-reactor-netty4/licenses/reactor-netty-http-1.1.26.jar.sha1 @@ -0,0 +1 @@ +41682e517e2808fc469d6b2b85fea48d0a7fe73b \ No newline at end of file diff --git a/plugins/transport-reactor-netty4/src/main/java/org/opensearch/http/reactor/netty4/ReactorNetty4HttpServerTransport.java b/plugins/transport-reactor-netty4/src/main/java/org/opensearch/http/reactor/netty4/ReactorNetty4HttpServerTransport.java index 3dcee4e8ec045..77648ed7e785c 100644 --- a/plugins/transport-reactor-netty4/src/main/java/org/opensearch/http/reactor/netty4/ReactorNetty4HttpServerTransport.java +++ b/plugins/transport-reactor-netty4/src/main/java/org/opensearch/http/reactor/netty4/ReactorNetty4HttpServerTransport.java @@ -18,6 +18,7 @@ import org.opensearch.common.util.concurrent.OpenSearchExecutors; import org.opensearch.common.util.io.IOUtils; import org.opensearch.common.util.net.NetUtils; +import org.opensearch.core.common.unit.ByteSizeUnit; import org.opensearch.core.common.unit.ByteSizeValue; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.http.AbstractHttpServerTransport; @@ -87,6 +88,19 @@ public class ReactorNetty4HttpServerTransport extends AbstractHttpServerTranspor private static final String SETTING_KEY_HTTP_NETTY_MAX_COMPOSITE_BUFFER_COMPONENTS = "http.netty.max_composite_buffer_components"; private static final ByteSizeValue MTU = new ByteSizeValue(Long.parseLong(System.getProperty("opensearch.net.mtu", "1500"))); + /** + * Configure the maximum length of the content of the HTTP/2.0 clear-text upgrade request. + * By default the server will reject an upgrade request with non-empty content, + * because the upgrade request is most likely a GET request. If the client sends + * a non-GET upgrade request, {@link #h2cMaxContentLength} specifies the maximum + * length of the content of the upgrade request. + */ + public static final Setting SETTING_H2C_MAX_CONTENT_LENGTH = Setting.byteSizeSetting( + "h2c.max_content_length", + new ByteSizeValue(65536, ByteSizeUnit.KB), + Property.NodeScope + ); + /** * The number of Reactor Netty HTTP workers */ @@ -133,6 +147,7 @@ public class ReactorNetty4HttpServerTransport extends AbstractHttpServerTranspor private final ByteSizeValue maxInitialLineLength; private final ByteSizeValue maxHeaderSize; private final ByteSizeValue maxChunkSize; + private final ByteSizeValue h2cMaxContentLength; private final SecureHttpTransportSettingsProvider secureHttpTransportSettingsProvider; private volatile SharedGroupFactory.SharedGroup sharedGroup; private volatile DisposableServer disposableServer; @@ -208,6 +223,7 @@ public ReactorNetty4HttpServerTransport( this.maxCompositeBufferComponents = SETTING_HTTP_NETTY_MAX_COMPOSITE_BUFFER_COMPONENTS.get(settings); this.maxChunkSize = SETTING_HTTP_MAX_CHUNK_SIZE.get(settings); this.maxHeaderSize = SETTING_HTTP_MAX_HEADER_SIZE.get(settings); + this.h2cMaxContentLength = SETTING_H2C_MAX_CONTENT_LENGTH.get(settings); this.maxInitialLineLength = SETTING_HTTP_MAX_INITIAL_LINE_LENGTH.get(settings); this.secureHttpTransportSettingsProvider = secureHttpTransportSettingsProvider; } @@ -228,6 +244,7 @@ protected HttpServerChannel bind(InetSocketAddress socketAddress) throws Excepti .compress(true) .httpRequestDecoder( spec -> spec.maxChunkSize(maxChunkSize.bytesAsInt()) + .h2cMaxContentLength(h2cMaxContentLength.bytesAsInt()) .maxHeaderSize(maxHeaderSize.bytesAsInt()) .maxInitialLineLength(maxInitialLineLength.bytesAsInt()) .allowPartialChunks(false) diff --git a/plugins/transport-reactor-netty4/src/main/java/org/opensearch/transport/reactor/ReactorNetty4Plugin.java b/plugins/transport-reactor-netty4/src/main/java/org/opensearch/transport/reactor/ReactorNetty4Plugin.java index 6e5b0215b58a4..90ed1fe729d3a 100644 --- a/plugins/transport-reactor-netty4/src/main/java/org/opensearch/transport/reactor/ReactorNetty4Plugin.java +++ b/plugins/transport-reactor-netty4/src/main/java/org/opensearch/transport/reactor/ReactorNetty4Plugin.java @@ -57,7 +57,7 @@ public ReactorNetty4Plugin() {} */ @Override public List> getSettings() { - return Arrays.asList(/* no setting registered since we're picking the onces from Netty 4 transport */); + return Arrays.asList(ReactorNetty4HttpServerTransport.SETTING_H2C_MAX_CONTENT_LENGTH); } /** diff --git a/server/src/main/resources/org/opensearch/bootstrap/test-framework.policy b/server/src/main/resources/org/opensearch/bootstrap/test-framework.policy index c62adda511140..e1a3b4618035e 100644 --- a/server/src/main/resources/org/opensearch/bootstrap/test-framework.policy +++ b/server/src/main/resources/org/opensearch/bootstrap/test-framework.policy @@ -120,7 +120,7 @@ grant codeBase "${codebase.httpcore5}" { grant codeBase "${codebase.httpclient5}" { // httpclient5 makes socket connections for rest tests - permission java.net.SocketPermission "*", "connect"; + permission java.net.SocketPermission "*", "connect,resolve"; }; grant codeBase "${codebase.httpcore-nio}" {