Repository navigation
Conversation
7e97dd6 to
4183409
Compare
pjfanning
left a comment
There was a problem hiding this comment.
Thanks for the work on this. Before going further with the details, I think we should consider bringing in the wider Pekko team to decide whether we need to implement features like this at all, for example with a thread on the dev list.
My reasons for asking:
- #1588 was opened shortly before this PR and has had no discussion. It does not name a user or a use case; the motivation is that RFC 9113 section 8.5 defines CONNECT.
- The benefit looks narrow. This is server side only, there is no HTTP/2 CONNECT client API, the application has to do the outbound connection itself, and extended CONNECT (WebSocket over HTTP/2, MASQUE) is out of scope.
- On #981 @jrudolph noted that CONNECT is not really supported and was reluctant to add code for it.
- It adds new public API (
Http2ConnectData, an attribute key, a setting) and new state inHttp2StreamHandlingthat we would have to maintain and keep compatible.
This is not specific to CONNECT. For new opt-in protocol features in general, I would like us to agree as a team on whether there is demand before the implementation and review effort goes in.
So that the review is not wasted if we do go ahead, here is what I found. I read the code and tests, and also ran the CONNECT tests in Http2ServerSpec locally together with some extra cases of my own. These behaved correctly:
- a rejection with a body (407 with an entity) is sent as HEADERS, DATA with END_STREAM, then
RST_STREAM(NO_ERROR), in that order accept(...)combined with a non-2xx status is treated as an ordinary rejection- trailers from the peer on an accepted tunnel give
RST_STREAM(PROTOCOL_ERROR)
None of those three has a test in the PR, and neither does a malformed target (see inline). There is also no Java test: the Java accept overload is only called from a Scala spec. The description says TLS was not exercised.
Smaller points:
- Nothing new has
@since 2.1.0or@ApiMayChange(Http2ConnectData, bothAttributeKeys.http2ConnectData,acceptConnectRequests/withAcceptConnectRequests/getAcceptConnectRequests). - The 2xx tunnel response still carries
content-type: application/octet-stream, which has no meaning for a tunnel. - After the trailers reset, the application's
datasource fails with "The HTTP/2 connection was shut down while the request was still ongoing", which is misleading when only that stream was reset.
The rest is inline.
| def apply(config: Config): Http2ServerSettings = Http2ServerSettingsImpl(config) | ||
| def apply(configOverrides: String): Http2ServerSettings = Http2ServerSettingsImpl(configOverrides) | ||
|
|
||
| private final case class ConnectOptions(custom: Option[Http2InternalServerSettings]) |
There was a problem hiding this comment.
This stores the flag by wrapping the internalSettings slot, which is the approach we moved away from on #981 (and #1556): it leaks into toString/equals and is easy to break with a later withInternalSettings. Http2ServerSettingsImpl is private[http], so could this be a normal field with MiMa filters for the constructor and copy, as #981 now does? The two PRs also change the same lines, so they will conflict.
There was a problem hiding this comment.
Thanks for taking the flag out of internalSettings, and for the other changes in this revision (the javadsl/scaladsl split of Http2ConnectData, @since / @ApiMayChange, and the warning plus 500 for an unaccepted 2xx; I have resolved those two threads). I do not think the subclass is the right replacement though.
#981, #1556 and #1589 each add a setting to Http2ServerSettingsImpl, and in their latest revisions each avoids a MiMa filter in a different way: #981 wraps internalSettings in AsteriskOptionsEnabled, #1556 wraps it in ServerHpackSettings, and #1589 subclasses the case class with ConnectEnabledSettings. These will not compose once more than one is merged. For example, acceptAsteriskOptions checks that the outermost internalSettings value is an AsteriskOptionsEnabled, which is no longer true if the HPACK wrapper is applied on top, and the #1589 subclass has to re-declare copy with the full parameter list, so it breaks as soon as another PR adds a field.
I understand the reason given (the existing setters have inferred return types, so the case class shape leaks). But the class is private[http], and I think a MiMa filter for its constructor and copy is the smaller cost compared with three workarounds on the same slot. Could we settle on one approach for all three PRs? My preference is a normal constructor field with the filters.
| if (tlsSessionInfoHeader.isDefined) headers += tlsSessionInfoHeader.get | ||
|
|
||
| val entity = subStream.createEntity(contentLength, contentType) | ||
| val entity = if (regularConnect) HttpEntity.Empty else subStream.createEntity(contentLength, contentType) |
There was a problem hiding this comment.
Why is the request entity empty with the tunnel bytes moved into an attribute, rather than the tunnel bytes being the request entity?
With the stream hidden in an attribute, the generic entity handling does not see it: discardEntityBytes, toStrict, size limits and anything else that works on request.entity. An accepted tunnel whose data source the application never runs (for example a one-way accept(HttpEntity("hello"))) keeps the incoming side of the stream open with nothing to drain it, until the peer ends the stream or the connection closes. If there is a reason the entity cannot be used, could it go in the PR description and the docs?
| checkRequiredPseudoHeader(":authority", authority) | ||
| if (scheme != null || pathAndRawQuery != null || authority.host.isEmpty || authority.port <= 0 || | ||
| authority.port > 65535 || authority.userinfo.nonEmpty) | ||
| protocolError("Invalid regular CONNECT request target") |
There was a problem hiding this comment.
protocolError is a connection error here. I checked locally: a CONNECT that also carries :scheme and :path, and one whose :authority has no port, both get GOAWAY(PROTOCOL_ERROR). RFC 9113 section 8.5 says such a request is malformed, and section 8.1.1 makes a malformed request a stream error.
This is how the other malformed pseudo-header cases in this file behave today, so it is consistent, but with tunnels it means one bad CONNECT also tears down every established tunnel on the same connection. Would a stream-level RST_STREAM(PROTOCOL_ERROR) be better for this case? Either way, could tests be added for these two inputs, plus userinfo in the authority and port 0?
f3ba5fb to
23f7d29
Compare
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.
Motivation: Keep the explicit server-side CONNECT opt-in composable with other HTTP/2 settings while preserving released JVM constructor and copy linkage. Modification: Retain the existing application-owned draft on current main. Replace the settings subclass with a default-off field; keep the released constructor and copy bridges and keep internal settings independent. Result: The draft's default behavior and tunnel API are unchanged. Existing copies preserve the new setting. Tunnel lifecycle design remains open. Tests: - Focused settings: 4 passed on each of Scala 2.13.18 and 3.3.9. - Java wither smoke, linked 2.0.0 consumers, and scoped MiMa passed on both. - Compatibility-guide checker: 2 passed on Scala 2.13.18. - Cached overlays; no full CI, native sbt test graph, or tunnel tests. References: Refs apache#1588, apache#1589, apache#981, apache#1556. https://www.rfc-editor.org/rfc/rfc9113.html#section-8.5
23f7d29 to
a882acf
Compare
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.
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.
Motivation
Support standard HTTP/2 CONNECT as described in RFC 9113 §8.5.
Modification
Provide an explicit opt-in on the server for application-owned CONNECT tunnels in Scala and Java. The application must explicitly accept the tunnel. Non-success replies remain ordinary HTTP responses. An unaccepted success becomes a 500, with one warning per connection. The default-off opt-in is a dedicated server setting, separate from
internalSettings. Compatibility bridges retain the supported released constructor andcopysignatures; the private implementation's generated product shape is not preserved. No automatic outbound dial, default proxy behavior, or RFC 8441 Extended CONNECT support is added.Result
Applications that opt in can handle accepted streams with backpressure and half-close; applications that do not opt in retain their existing behavior.
Tests
On this rebase, the four focused settings checks passed on both Scala 2.13.18 and 3.3.9. Java settings calls, a caller compiled against Pekko HTTP 2.0.0, scoped MiMa and the two docs-checker assertions passed. The isolated settings check also composed the CONNECT, OPTIONS and HPACK setting fields; this was not a merge or a full CI run. The CONNECT transport tests from the earlier draft were not rerun on this head.
This remains a draft. Stream-local error reporting, tunnel lifecycle, and agreement on the public API are still open.
References
Closes #1588. RFC 9113 §8.5.