Skip to content
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

Initial support for RFC 9298 "Proxying UDP in HTTP" #203

Merged
merged 3 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions h3/src/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,23 @@ pub struct Protocol(ProtocolInner);
impl Protocol {
/// WebTransport protocol
pub const WEB_TRANSPORT: Protocol = Protocol(ProtocolInner::WebTransport);
/// RFC 9298 protocol
pub const CONNECT_UDP: Protocol = Protocol(ProtocolInner::ConnectUdp);

/// Return a &str representation of the `:protocol` pseudo-header value
#[inline]
pub fn as_str(&self) -> &str {
match self.0 {
ProtocolInner::WebTransport => "webtransport",
ProtocolInner::ConnectUdp => "connect-udp",
}
}
}

#[derive(Copy, PartialEq, Debug, Clone)]
enum ProtocolInner {
WebTransport,
ConnectUdp,
}

/// Error when parsing the protocol
Expand All @@ -36,6 +48,7 @@ impl FromStr for Protocol {
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"webtransport" => Ok(Self(ProtocolInner::WebTransport)),
"connect-udp" => Ok(Self(ProtocolInner::ConnectUdp)),
_ => Err(InvalidProtocol),
}
}
Expand Down
4 changes: 4 additions & 0 deletions h3/src/proto/headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ impl Iterator for HeaderIter {
if let Some(status) = pseudo.status.take() {
return Some((":status", status.as_str()).into());
}

if let Some(protocol) = pseudo.protocol.take() {
return Some((":protocol", protocol.as_str().as_bytes()).into());
}
}

self.pseudo = None;
Expand Down