Skip to content

refactor!: make the CONNECT request optional for raw QUIC sessions#326

Open
kixelated wants to merge 1 commit into
mainfrom
claude/raw-quic-url-sni-c6b4be
Open

refactor!: make the CONNECT request optional for raw QUIC sessions#326
kixelated wants to merge 1 commit into
mainfrom
claude/raw-quic-url-sni-c6b4be

Conversation

@kixelated

Copy link
Copy Markdown
Collaborator

What

Raw QUIC (a moq ALPN with no WebTransport CONNECT) has no in-band request URL, but Session::raw() required a ConnectRequest. Callers had to synthesize one from the TLS SNI purely to satisfy the signature — and then discard it. Since SNI is optional (a client dialing a bare IP sends none, per RFC 6066), that synthesis also imposed a needless "SNI is required" constraint on the accept path.

This makes the request optional so the type tells the truth:

  • Session::raw(conn, response) — the request parameter is gone (quinn, noq, quiche)
  • Session::request() -> Option<&ConnectRequest>
  • web_transport::Session::url() -> Option<&Url>

Why this shape

response stays on raw(). It carries the negotiated ALPN, which protocol() reads. Dropping it would silently lose the ALPN on exactly the path this change exists to serve.

No path() or host() accessor. Decomposing the URL was only ever needed to work around the synthesized authority. host() in particular would merge an unauthenticated :authority header with a cert-bound SNI behind one name, hiding which of the two a caller was trusting — the security property would depend on the transport. iroh already models this correctly (Session::raw(conn), request() -> Option<..>); the other backends now match it.

ConnectRequest.url is unchanged. It's still needed to encode the :scheme, :authority, and :path pseudo-headers, and it's what downstream reads.

Bindings untouched. FFI, Node, and the browser have no raw QUIC support, so url() is always Some there. Making it nullable would have broken the Python/JS query-string coverage for no gain.

wasm returns Some unconditionally so the signature is identical across targets and cross-platform callers still compile.

Tests

Adds rs/web-transport-quinn/tests/raw.rs, covering raw sessions for the first time: no request, ALPN surfaced via protocol(), and streams round-tripping without the WebTransport header.

Reviewers should know these are mostly compile-time guards — the old three-argument signature wouldn't build against them at all. Only raw_session_streams_omit_webtransport_header exercises real behavior. There's no bug being fixed here, so there's no failing-before case to capture.

The tests are gated on #[cfg(any(feature = "aws-lc-rs", feature = "ring"))] and pass an explicit crypto provider, matching the crate's own builders: --all-features enables both backends, leaving rustls unable to pick a process-level default. Verified under default, --all-features, ring-only, and --no-default-features.

Verification

just check and just test both pass (clippy -D warnings on native and wasm32, cargo fmt --check, full test suite).

Follow-up

Unblocks deleting the moqt://{sni} synthesis in moq-native, where the raw arm collapses to Self::Raw { connection, response }. Error::BuildUrl dies with it, and Error::MissingServerName is already orphaned there.

Breaking

Session::raw() no longer takes a ConnectRequest; Session::request() and web_transport::Session::url() now return Option. Affects web-transport, web-transport-quinn, web-transport-noq, and web-transport-quiche.

🤖 Generated with Claude Code

Raw QUIC carries no in-band request URL, but `Session::raw()` required a
`ConnectRequest`. Callers had to synthesize a URL from the TLS SNI purely to
satisfy the signature, and that URL was then discarded. SNI is optional (a
client dialing a bare IP sends none, per RFC 6066), so the synthesis also
forced a needless "SNI is required" constraint on the accept path.

Drop the request from `Session::raw()` and make it optional instead:

  - `Session::raw(conn, response)` in the quinn, noq, and quiche backends
  - `Session::request() -> Option<&ConnectRequest>`
  - `web_transport::Session::url() -> Option<&Url>`

The response stays on `raw()` because it carries the negotiated ALPN, which
`protocol()` reads. The wasm router returns `Some` unconditionally so the
signature is identical across targets and cross-platform callers still compile.

No `path()` or `host()` accessor is added. Decomposing the URL was only ever
needed to paper over the synthesized authority, and combining an unauthenticated
`:authority` header with a cert-bound SNI behind one accessor would hide which
of the two a caller was trusting.

`ConnectRequest.url` is unchanged: it is still needed to encode the `:scheme`,
`:authority`, and `:path` pseudo-headers. The FFI, Node, and browser bindings
have no raw QUIC support, so their `url()` accessors are untouched.

Adds tests/raw.rs, which covers raw sessions for the first time.

BREAKING CHANGE: `Session::raw()` no longer takes a `ConnectRequest`, and both
`Session::request()` and `web_transport::Session::url()` now return an `Option`.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @kixelated, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9cb4b541-2404-4538-9ab3-667601b35b06

📥 Commits

Reviewing files that changed from the base of the PR and between bd7ab77 and f233270.

📒 Files selected for processing (7)
  • rs/web-transport-noq/src/session.rs
  • rs/web-transport-quiche/src/connection.rs
  • rs/web-transport-quinn/Cargo.toml
  • rs/web-transport-quinn/src/session.rs
  • rs/web-transport-quinn/tests/raw.rs
  • rs/web-transport/src/quinn.rs
  • rs/web-transport/src/wasm.rs

Walkthrough

Raw QUIC sessions now omit CONNECT requests, so session and connection request accessors return optional values. Raw constructors no longer accept a request argument. Native and WebAssembly URL accessors also return optional URLs. New QUIC integration tests configure a non-HTTP/3 ALPN and verify request absence, protocol propagation, and plain stream payload exchange.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: making CONNECT requests optional for raw QUIC sessions.
Description check ✅ Passed The description directly describes the API refactor, rationale, and tests, all matching the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch claude/raw-quic-url-sni-c6b4be

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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