diff --git a/client/src/main/java/org/asynchttpclient/AsyncHttpClientConfig.java b/client/src/main/java/org/asynchttpclient/AsyncHttpClientConfig.java index 766797a87..6d2b405d5 100644 --- a/client/src/main/java/org/asynchttpclient/AsyncHttpClientConfig.java +++ b/client/src/main/java/org/asynchttpclient/AsyncHttpClientConfig.java @@ -287,10 +287,10 @@ default boolean isHttp2Enabled() { } /** - * @return the HTTP/2 initial window size in bytes, defaults to 65535 + * @return the HTTP/2 initial window size in bytes, defaults to 16777216 (16 MiB) */ default int getHttp2InitialWindowSize() { - return 65_535; + return 16_777_216; } /** 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 1a41778b8..d7090e74d 100644 --- a/client/src/main/resources/org/asynchttpclient/config/ahc-default.properties +++ b/client/src/main/resources/org/asynchttpclient/config/ahc-default.properties @@ -55,7 +55,7 @@ org.asynchttpclient.ioThreadsCount=-1 org.asynchttpclient.hashedWheelTimerTickDuration=100 org.asynchttpclient.hashedWheelTimerSize=512 org.asynchttpclient.expiredCookieEvictionDelay=30000 -org.asynchttpclient.http2InitialWindowSize=65535 +org.asynchttpclient.http2InitialWindowSize=16777216 org.asynchttpclient.http2MaxFrameSize=16384 org.asynchttpclient.http2HeaderTableSize=4096 org.asynchttpclient.http2MaxHeaderListSize=8192 diff --git a/client/src/test/java/org/asynchttpclient/DefaultAsyncHttpClientConfigTest.java b/client/src/test/java/org/asynchttpclient/DefaultAsyncHttpClientConfigTest.java index d97a61d8a..6d00754f3 100644 --- a/client/src/test/java/org/asynchttpclient/DefaultAsyncHttpClientConfigTest.java +++ b/client/src/test/java/org/asynchttpclient/DefaultAsyncHttpClientConfigTest.java @@ -32,6 +32,22 @@ void testHttp2MaxDecompressedResponseSize_ZeroDisables() { assertEquals(0L, config.getHttp2MaxDecompressedResponseSize(), "0 must disable the limit"); } + @Test + void testHttp2InitialWindowSize_DefaultIs16MiB() { + DefaultAsyncHttpClientConfig config = new DefaultAsyncHttpClientConfig.Builder().build(); + assertEquals(16 * 1024 * 1024, config.getHttp2InitialWindowSize(), + "Default HTTP/2 initial window size should be 16 MiB (matches the JDK HttpClient and OkHttp defaults)"); + } + + @Test + void testHttp2InitialWindowSize_SetCustom() { + DefaultAsyncHttpClientConfig config = new DefaultAsyncHttpClientConfig.Builder() + .setHttp2InitialWindowSize(65_535) + .build(); + assertEquals(65_535, config.getHttp2InitialWindowSize(), + "Builder must plumb the configured value through"); + } + @Test void testStripAuthorizationOnRedirect_DefaultIsFalse() { DefaultAsyncHttpClientConfig config = new DefaultAsyncHttpClientConfig.Builder().build();