Skip to content

Create API for http/3 extensions like WebTransport #293

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Ruben2424 opened this issue Mar 27, 2025 · 0 comments
Open

Create API for http/3 extensions like WebTransport #293

Ruben2424 opened this issue Mar 27, 2025 · 0 comments
Labels
B-rfc Blocked: request for comments. Needs more discussion. C-feature Category: feature. This is adding a new feature.

Comments

@Ruben2424
Copy link
Contributor

Current Solution for WebTransport

The Solution for WebTransport wraps the server::Connection in a Mutex to allow listening to incoming streams (uni and bidi) and also to open new steams.

pub struct WebTransportSession<C, B>
where
C: quic::Connection<B>,
Connection<C, B>: HandleDatagramsExt<C, B>,
B: Buf,
{
// See: https://datatracker.ietf.org/doc/html/draft-ietf-webtrans-http3/#section-2-3
session_id: SessionId,
/// The underlying HTTP/3 connection
server_conn: Mutex<Connection<C, B>>,
connect_stream: RequestStream<C::BidiStream, B>,
opener: Mutex<C::OpenStreams>,
}

Additional resources like new Settings, Streams, Frames or Protocols for the :protocol pseudo header are defined and parsed within h3 itself and not h3-webtransport.

webtransport frames for example are atm handled in the h3 core.

h3/h3/src/proto/frame.rs

Lines 86 to 94 in 9b02824

// Webtransport streams need special handling as they have no length.
//
// See: https://datatracker.ietf.org/doc/html/draft-ietf-webtrans-http3/#section-4.2
if ty == FrameType::WEBTRANSPORT_BI_STREAM {
#[cfg(feature = "tracing")]
tracing::trace!("webtransport frame");
return Ok(Frame::WebTransportStream(SessionId::decode(buf)?));
}

So new extensions require changes in h3 itself, which can become very complicated.
A few references: #236 #273

Loose thoughts about what features such an extension API might require

An Extension API IMO should have the following features:

  • Ability to send custom Settings, Streams, Frames and Protocols for the :protocol pseudo header
  • Ability to react to custom Settings, Streams, Frames and Protocols for the :protocol pseudo header
  • Acces to the Quic types which implement h3-quic traits and potentially acces to some lower level structs like FrameStream or BufRecvStream

Some loose ideas

I have a few ideas on how this could be achieved, but nothing completely thought through.

Give another generic Parameter to the h3 connection
An additional generic Parameter could be added to ConnectionInner (or maybe client::Connection / server::Connection directly?).
This generic Parameter could either be:

  • A custom Trait defined in h3 where each each "event" is a method
  • Fn(Args) -> () + Clone. With Args as an Enum with a variant for each "event"

When specific events occur while polling the the connection, the extension could react for example to the event when a unknown stream or frame is received.

When using traits this could be combined with custom types for custom Settings, Streams, Frames, etc.

Access to low level types in order to start streams and send.

Open Question

  • Where should the CONNECT Request be handled? h3? extension? user?

Whats next

  • please share your thoughts on this
  • figure out more details (maybe while implementing a prototype)
@Ruben2424 Ruben2424 added B-rfc Blocked: request for comments. Needs more discussion. C-feature Category: feature. This is adding a new feature. labels Mar 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B-rfc Blocked: request for comments. Needs more discussion. C-feature Category: feature. This is adding a new feature.
Projects
None yet
Development

No branches or pull requests

1 participant