summaryrefslogtreecommitdiff
path: root/ext/net/raw.rs
diff options
context:
space:
mode:
authorMatt Mastracci <matthew@mastracci.com>2023-04-24 23:24:40 +0200
committerGitHub <noreply@github.com>2023-04-24 23:24:40 +0200
commitbb74e75a049768c2949aa08de6752a16813b97de (patch)
tree0c6af6d5ef1b8e8aff878d9e2aa8c32bee1c4c39 /ext/net/raw.rs
parent0e97fa4d5f056e12d3c0704bfb7bcdc56316ef94 (diff)
feat(ext/http): h2c for http/2 (#18817)
This implements HTTP/2 prior-knowledge connections, allowing clients to request HTTP/2 over plaintext or TLS-without-ALPN connections. If a client requests a specific protocol via ALPN (`h2` or `http/1.1`), however, the protocol is forced and must be used.
Diffstat (limited to 'ext/net/raw.rs')
-rw-r--r--ext/net/raw.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/ext/net/raw.rs b/ext/net/raw.rs
index 74cc10d63..3b50af41e 100644
--- a/ext/net/raw.rs
+++ b/ext/net/raw.rs
@@ -30,6 +30,25 @@ pub enum NetworkStream {
Unix(#[pin] UnixStream),
}
+impl From<TcpStream> for NetworkStream {
+ fn from(value: TcpStream) -> Self {
+ NetworkStream::Tcp(value)
+ }
+}
+
+impl From<TlsStream> for NetworkStream {
+ fn from(value: TlsStream) -> Self {
+ NetworkStream::Tls(value)
+ }
+}
+
+#[cfg(unix)]
+impl From<UnixStream> for NetworkStream {
+ fn from(value: UnixStream) -> Self {
+ NetworkStream::Unix(value)
+ }
+}
+
/// A raw stream of one of the types handled by this extension.
#[derive(Copy, Clone, PartialEq, Eq)]
pub enum NetworkStreamType {