From 517120186024db52bbe2fc73356ece6623170de2 Mon Sep 17 00:00:00 2001 From: CoolTomatos <24667806+CoolTomatos@users.noreply.github.com> Date: Fri, 26 Dec 2025 16:38:10 +0100 Subject: [PATCH 1/3] Disable settings_push_enable on the H2Config. --- .../core5/http2/impl/nio/bootstrap/H2ServerBootstrap.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/bootstrap/H2ServerBootstrap.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/bootstrap/H2ServerBootstrap.java index 1d2aab3ce9..ca67ac2c3b 100644 --- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/bootstrap/H2ServerBootstrap.java +++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/bootstrap/H2ServerBootstrap.java @@ -163,6 +163,7 @@ public final H2ServerBootstrap setVersionPolicy(final HttpVersionPolicy versionP * @return this instance. */ public final H2ServerBootstrap setH2Config(final H2Config h2Config) { + Args.check(!h2Config.isPushEnabled(), "A server MUST NOT set enable_push according to RFC-9113 6.5.2."); this.h2Config = h2Config; return this; } @@ -212,7 +213,6 @@ public final H2ServerBootstrap setIOSessionDecorator(final Decorator return this; } - /** * Sets {@link IOReactorMetricsListener} instance. * @@ -274,6 +274,7 @@ public final H2ServerBootstrap setStreamListener(final Http1StreamListener http1 this.http1StreamListener = http1StreamListener; return this; } + /** * @return this instance. * @deprecated Use {@link RequestRouter}. @@ -522,7 +523,7 @@ public HttpAsyncServer create() { final ServerH2StreamMultiplexerFactory http2StreamHandlerFactory = new ServerH2StreamMultiplexerFactory( httpProcessor != null ? httpProcessor : H2Processors.server(), handlerFactory, - h2Config != null ? h2Config : H2Config.DEFAULT, + h2Config != null ? h2Config : H2Config.custom().setPushEnabled(false).build(), charCodingConfig != null ? charCodingConfig : CharCodingConfig.DEFAULT, h2StreamListener, frameFactory); @@ -553,5 +554,4 @@ public HttpAsyncServer create() { return new HttpAsyncServer(ioEventHandlerFactory, ioReactorConfig, ioSessionDecorator, exceptionCallback, sessionListener, threadPoolListener, null, actualCanonicalHostName); } - } From b3ca76a9e6f641af551bf0ac5c892e59da22baab Mon Sep 17 00:00:00 2001 From: CoolTomatos <24667806+CoolTomatos@users.noreply.github.com> Date: Fri, 26 Dec 2025 20:42:13 +0100 Subject: [PATCH 2/3] Address comments. --- .../hc/core5/http2/impl/nio/bootstrap/H2ServerBootstrap.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/bootstrap/H2ServerBootstrap.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/bootstrap/H2ServerBootstrap.java index ca67ac2c3b..cb4058ee7a 100644 --- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/bootstrap/H2ServerBootstrap.java +++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/bootstrap/H2ServerBootstrap.java @@ -163,7 +163,7 @@ public final H2ServerBootstrap setVersionPolicy(final HttpVersionPolicy versionP * @return this instance. */ public final H2ServerBootstrap setH2Config(final H2Config h2Config) { - Args.check(!h2Config.isPushEnabled(), "A server MUST NOT set enable_push according to RFC-9113 6.5.2."); + Args.check(!h2Config.isPushEnabled(), "A server MUST NOT set enable_push to true"); this.h2Config = h2Config; return this; } @@ -213,6 +213,7 @@ public final H2ServerBootstrap setIOSessionDecorator(final Decorator return this; } + /** * Sets {@link IOReactorMetricsListener} instance. * @@ -274,7 +275,6 @@ public final H2ServerBootstrap setStreamListener(final Http1StreamListener http1 this.http1StreamListener = http1StreamListener; return this; } - /** * @return this instance. * @deprecated Use {@link RequestRouter}. @@ -554,4 +554,5 @@ public HttpAsyncServer create() { return new HttpAsyncServer(ioEventHandlerFactory, ioReactorConfig, ioSessionDecorator, exceptionCallback, sessionListener, threadPoolListener, null, actualCanonicalHostName); } + } From 370f2e7be2d49d6af8a91fa44b60ef4aad004cb7 Mon Sep 17 00:00:00 2001 From: CoolTomatos <24667806+CoolTomatos@users.noreply.github.com> Date: Sat, 27 Dec 2025 16:42:27 +0100 Subject: [PATCH 3/3] Address comments. --- .../hc/core5/http2/impl/nio/bootstrap/H2ServerBootstrap.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/bootstrap/H2ServerBootstrap.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/bootstrap/H2ServerBootstrap.java index cb4058ee7a..28bf832e82 100644 --- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/bootstrap/H2ServerBootstrap.java +++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/bootstrap/H2ServerBootstrap.java @@ -86,6 +86,8 @@ @SuppressWarnings("deprecation") public class H2ServerBootstrap { + private static final H2Config DEFAULT_H2_CONFIG = H2Config.custom().setPushEnabled(false).build(); + private final List>> routeEntries; private final List> filters; private String canonicalHostName; @@ -523,7 +525,7 @@ public HttpAsyncServer create() { final ServerH2StreamMultiplexerFactory http2StreamHandlerFactory = new ServerH2StreamMultiplexerFactory( httpProcessor != null ? httpProcessor : H2Processors.server(), handlerFactory, - h2Config != null ? h2Config : H2Config.custom().setPushEnabled(false).build(), + h2Config != null ? h2Config : DEFAULT_H2_CONFIG, charCodingConfig != null ? charCodingConfig : CharCodingConfig.DEFAULT, h2StreamListener, frameFactory);