Skip to content

feat: add opt-in HTTP/2 server push - #1800

Draft
He-Pin wants to merge 2 commits into
apache:mainfrom
He-Pin:feat/http2-opt-in-server-push
Draft

He-Pin wants to merge 2 commits into
apache:mainfrom
He-Pin:feat/http2-opt-in-server-push

Conversation

@He-Pin

@He-Pin He-Pin commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

Motivation

Applications with a ready companion representation can offer it on the same HTTP/2 connection without changing behavior for applications that leave the feature off or peers that disallow push.

Modification

  • Add the default-off server-only setting pekko.http.server.http2.server-push-enabled and typed Scala and Java plan factories.
  • Accept one explicit plan for a bodyless native HTTP/2 GET and a complete strict 200 OK companion representation at a rooted URI on the original origin. No request fields other than the origin are inherited.
  • Consider the offer only when peer permission, original request eligibility and immediate outbound demand allow it. The child uses its own server-assigned stream and the existing scheduler. The promise and ordinary responses use the same connection HPACK encoder.

Result

Server push is best effort. Offers are not queued; if a push does not start, the primary response takes its ordinary path. The API does not acknowledge delivery. No change to HTTP/1.1 fallback, HTTP/1.1 upgrade behavior, clients or the minimum Pekko Core version.

Tests

On JDK 17, Scala 2.13.18 and 3.3.9 each passed four named cases in one process: the producer/codec fixture first, then the three native cases (default off, Scala opt-in, Java opt-in). The producer fixture observes standard header values without replacing shared cached values and tracks reuse only for its custom header. This addresses the test isolation issue found by the broader CI run. A subsequent CI run found an abstract Scala settings getter was binary-incompatible. The getter now has a concrete default of false; the actual settings implementation still returns the configured value.

On the latest head both Scala axes passed the two focused settings tests. Scoped MiMa 1.2.1 backward checks of the Scala and Java settings API against Pekko HTTP 2.0.0 report zero problems on both axes, without any new filter. Earlier focused runs passed a named Java Jupiter case on each axis. The local tests use an in-memory typed native boundary, not sockets, a real TLS/ALPN handshake or an external peer. The GitHub test matrix still needs to pass on the updated head; full MiMa and the docs build were not run locally.

References

Stacked on #1556, which supplies the shared outbound HPACK policy. The proposed head includes a patch-equivalent replay of that PR onto Apache main, followed by one Server Push commit. It does not modify the original #1556 branch; the Apache-main comparison includes the parent patch until #1556 is merged.

Child-only diff: Server Push changes only

Keep this PR in Draft and do not merge it until #1556 has merged and this change is rebased on Apache main. Independent review and the required checks, including binary compatibility, must pass on that head.

RFC 9113 §6.5.2, §6.6 and §8.4.

Motivation:
High-cardinality outbound values can displace useful dynamic HPACK
table entries. Applications need an opt-in compression policy.

Modification:
Add role-specific configured names and an optional typed Scala/Java
policy. Use ordinary settings fields, independent of internalSettings;
preserve the released JVM constructors and copy descriptors. Keep the
Latin-1 guard, exact index reuse, and never-index behavior. Rebase on
current main and keep both imports required by the HTTP/2 server spec.

Result:
Unconfigured applications keep their existing behavior. A configured
policy can decline eligible new entries without changing index reuse.

Tests:
JDK 17 on Scala 2.13.18 and 3.3.9: 14 focused ordinary settings,
HPACK, and client/server tests per axis and a released 2.0.0 Scala
copy caller. Scoped settings MiMa and Scala formatting passed.

References:
Netty #18501, RFC 7541 Section 6.2.2; related apache#981 and apache#1589.
@He-Pin
He-Pin force-pushed the feat/http2-opt-in-server-push branch 2 times, most recently from 7d8be21 to f359a4e Compare November 27, 2026 23:29
@He-Pin
He-Pin force-pushed the feat/http2-opt-in-server-push branch from f359a4e to 0c7b022 Compare November 27, 2026 23:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant