File tree Expand file tree Collapse file tree 3 files changed +22
-2
lines changed Expand file tree Collapse file tree 3 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ documentation = "https://docs.rs/hyper-tls"
11
11
edition = " 2018"
12
12
13
13
[features ]
14
+ alpn = [" native-tls/alpn" ]
14
15
vendored = [" native-tls/vendored" ]
15
16
16
17
[dependencies ]
Original file line number Diff line number Diff line change 22
22
//! Ok(())
23
23
//! }
24
24
//! ```
25
+ //!
26
+ //! ## Crate Features
27
+ //!
28
+ //! - `alpn`: Enables `native-tls/alpn`, and if `h2` is negotiated, tells hyper.
25
29
#![ doc( html_root_url = "https://docs.rs/hyper-tls/0.5.0" ) ]
26
30
#![ cfg_attr( test, deny( warnings) ) ]
27
31
#![ deny( missing_docs) ]
Original file line number Diff line number Diff line change @@ -111,13 +111,28 @@ impl<T: Write + Read + Unpin> Write for MaybeHttpsStream<T> {
111
111
}
112
112
}
113
113
114
- impl < T : Connection + Unpin > Connection for MaybeHttpsStream < T > {
114
+ impl < T : Write + Read + Connection + Unpin > Connection for MaybeHttpsStream < T > {
115
115
fn connected ( & self ) -> Connected {
116
116
match self {
117
117
MaybeHttpsStream :: Http ( s) => s. connected ( ) ,
118
118
MaybeHttpsStream :: Https ( s) => {
119
- s. inner ( ) . get_ref ( ) . get_ref ( ) . get_ref ( ) . inner ( ) . connected ( )
119
+ let c = s. inner ( ) . get_ref ( ) . get_ref ( ) . get_ref ( ) . inner ( ) . connected ( ) ;
120
+ #[ cfg( feature = "alpn" ) ]
121
+ {
122
+ if negotiated_h2 ( s. inner ( ) . get_ref ( ) ) {
123
+ return c. negotiated_h2 ( ) ;
124
+ }
125
+ }
126
+ c
120
127
}
121
128
}
122
129
}
123
130
}
131
+
132
+ #[ cfg( feature = "alpn" ) ]
133
+ fn negotiated_h2 < T : std:: io:: Read + std:: io:: Write > ( s : & native_tls:: TlsStream < T > ) -> bool {
134
+ s. negotiated_alpn ( )
135
+ . unwrap_or ( None )
136
+ . map ( |list| list == & b"h2" [ ..] )
137
+ . unwrap_or ( false )
138
+ }
You can’t perform that action at this time.
0 commit comments