Skip to content

Commit 154ff8d

Browse files
authored
Add WebSocket :protocol extension per RFC 9220. (#236)
1 parent e75b509 commit 154ff8d

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

h3/src/ext.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ impl Protocol {
1515
pub const CONNECT_UDP: Protocol = Protocol(ProtocolInner::ConnectUdp);
1616
/// RFC 9484 protocol
1717
pub const CONNECT_IP: Protocol = Protocol(ProtocolInner::ConnectIp);
18+
/// RFC 9220 (WebSocket) protocol
19+
pub const WEBSOCKET: Protocol = Protocol(ProtocolInner::WebSocket);
1820

1921
/// Return a &str representation of the `:protocol` pseudo-header value
2022
#[inline]
@@ -23,6 +25,7 @@ impl Protocol {
2325
ProtocolInner::WebTransport => "webtransport",
2426
ProtocolInner::ConnectUdp => "connect-udp",
2527
ProtocolInner::ConnectIp => "connect-ip",
28+
ProtocolInner::WebSocket => "websocket",
2629
}
2730
}
2831
}
@@ -32,6 +35,7 @@ enum ProtocolInner {
3235
WebTransport,
3336
ConnectUdp,
3437
ConnectIp,
38+
WebSocket,
3539
}
3640

3741
/// Error when parsing the protocol
@@ -45,6 +49,7 @@ impl FromStr for Protocol {
4549
"webtransport" => Ok(Self(ProtocolInner::WebTransport)),
4650
"connect-udp" => Ok(Self(ProtocolInner::ConnectUdp)),
4751
"connect-ip" => Ok(Self(ProtocolInner::ConnectIp)),
52+
"websocket" => Ok(Self(ProtocolInner::WebSocket)),
4853
_ => Err(InvalidProtocol),
4954
}
5055
}

0 commit comments

Comments
 (0)