File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -1451,8 +1451,13 @@ impl proto::Peer for Peer {
1451
1451
}
1452
1452
1453
1453
let has_protocol = pseudo. protocol . is_some ( ) ;
1454
- if !is_connect && has_protocol {
1455
- malformed ! ( "malformed headers: :protocol on non-CONNECT request" ) ;
1454
+ if has_protocol {
1455
+ if is_connect {
1456
+ // Assert that we have the right type.
1457
+ b = b. extension :: < crate :: ext:: Protocol > ( pseudo. protocol . unwrap ( ) ) ;
1458
+ } else {
1459
+ malformed ! ( "malformed headers: :protocol on non-CONNECT request" ) ;
1460
+ }
1456
1461
}
1457
1462
1458
1463
if pseudo. status . is_some ( ) {
Original file line number Diff line number Diff line change @@ -1214,7 +1214,12 @@ async fn extended_connect_protocol_enabled_during_handshake() {
1214
1214
1215
1215
let mut srv = builder. handshake :: < _ , Bytes > ( io) . await . expect ( "handshake" ) ;
1216
1216
1217
- let ( _req, mut stream) = srv. next ( ) . await . unwrap ( ) . unwrap ( ) ;
1217
+ let ( req, mut stream) = srv. next ( ) . await . unwrap ( ) . unwrap ( ) ;
1218
+
1219
+ assert_eq ! (
1220
+ req. extensions( ) . get:: <crate :: ext:: Protocol >( ) ,
1221
+ Some ( & crate :: ext:: Protocol :: from_static( "the-bread-protocol" ) )
1222
+ ) ;
1218
1223
1219
1224
let rsp = Response :: new ( ( ) ) ;
1220
1225
stream. send_response ( rsp, false ) . unwrap ( ) ;
You can’t perform that action at this time.
0 commit comments