Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1451,8 +1451,13 @@ impl proto::Peer for Peer {
}

let has_protocol = pseudo.protocol.is_some();
if !is_connect && has_protocol {
malformed!("malformed headers: :protocol on non-CONNECT request");
if has_protocol {
if is_connect {
// Assert that we have the right type.
b = b.extension::<crate::ext::Protocol>(pseudo.protocol.unwrap());
} else {
malformed!("malformed headers: :protocol on non-CONNECT request");
}
}

if pseudo.status.is_some() {
Expand Down
7 changes: 6 additions & 1 deletion tests/h2-tests/tests/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1214,7 +1214,12 @@ async fn extended_connect_protocol_enabled_during_handshake() {

let mut srv = builder.handshake::<_, Bytes>(io).await.expect("handshake");

let (_req, mut stream) = srv.next().await.unwrap().unwrap();
let (req, mut stream) = srv.next().await.unwrap().unwrap();

assert_eq!(
req.extensions().get::<crate::ext::Protocol>(),
Some(&crate::ext::Protocol::from_static("the-bread-protocol"))
);

let rsp = Response::new(());
stream.send_response(rsp, false).unwrap();
Expand Down