@@ -15,6 +15,7 @@ use super::{ping, PipeToSendStream, SendBuf};
15
15
use crate :: body:: HttpBody ;
16
16
use crate :: common:: exec:: ConnStreamExec ;
17
17
use crate :: common:: { date, task, Future , Pin , Poll } ;
18
+ use crate :: ext:: Protocol ;
18
19
use crate :: headers;
19
20
use crate :: proto:: h2:: ping:: Recorder ;
20
21
use crate :: proto:: h2:: { H2Upgraded , UpgradedSendStream } ;
@@ -41,6 +42,7 @@ pub(crate) struct Config {
41
42
pub ( crate ) initial_conn_window_size : u32 ,
42
43
pub ( crate ) initial_stream_window_size : u32 ,
43
44
pub ( crate ) max_frame_size : u32 ,
45
+ pub ( crate ) enable_connect_protocol : bool ,
44
46
pub ( crate ) max_concurrent_streams : Option < u32 > ,
45
47
#[ cfg( feature = "runtime" ) ]
46
48
pub ( crate ) keep_alive_interval : Option < Duration > ,
@@ -56,6 +58,7 @@ impl Default for Config {
56
58
initial_conn_window_size : DEFAULT_CONN_WINDOW ,
57
59
initial_stream_window_size : DEFAULT_STREAM_WINDOW ,
58
60
max_frame_size : DEFAULT_MAX_FRAME_SIZE ,
61
+ enable_connect_protocol : false ,
59
62
max_concurrent_streams : None ,
60
63
#[ cfg( feature = "runtime" ) ]
61
64
keep_alive_interval : None ,
@@ -117,6 +120,9 @@ where
117
120
if let Some ( max) = config. max_concurrent_streams {
118
121
builder. max_concurrent_streams ( max) ;
119
122
}
123
+ if config. enable_connect_protocol {
124
+ builder. enable_connect_protocol ( ) ;
125
+ }
120
126
let handshake = builder. handshake ( io) ;
121
127
122
128
let bdp = if config. adaptive_window {
@@ -280,7 +286,7 @@ where
280
286
281
287
let is_connect = req. method ( ) == Method :: CONNECT ;
282
288
let ( mut parts, stream) = req. into_parts ( ) ;
283
- let ( req, connect_parts) = if !is_connect {
289
+ let ( mut req, connect_parts) = if !is_connect {
284
290
(
285
291
Request :: from_parts (
286
292
parts,
@@ -307,6 +313,10 @@ where
307
313
)
308
314
} ;
309
315
316
+ if let Some ( protocol) = req. extensions_mut ( ) . remove :: < h2:: ext:: Protocol > ( ) {
317
+ req. extensions_mut ( ) . insert ( Protocol :: from_inner ( protocol) ) ;
318
+ }
319
+
310
320
let fut = H2Stream :: new ( service. call ( req) , connect_parts, respond) ;
311
321
exec. execute_h2stream ( fut) ;
312
322
}
0 commit comments