Skip to content

Commit 95a0d59

Browse files
committed
Do not always require an authority
This fixes connections where no authority is provide, for example when using UNIX domain sockets. Signed-off-by: Sascha Grunert <[email protected]>
1 parent a193237 commit 95a0d59

File tree

2 files changed

+2
-35
lines changed

2 files changed

+2
-35
lines changed

src/server.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -1393,14 +1393,8 @@ impl proto::Peer for Peer {
13931393
// A request translated from HTTP/1 must not include the :authority
13941394
// header
13951395
if let Some(authority) = pseudo.authority {
1396-
let maybe_authority = uri::Authority::from_maybe_shared(authority.clone().into_inner());
1397-
parts.authority = Some(maybe_authority.or_else(|why| {
1398-
malformed!(
1399-
"malformed headers: malformed authority ({:?}): {}",
1400-
authority,
1401-
why,
1402-
)
1403-
})?);
1396+
parts.authority =
1397+
uri::Authority::from_maybe_shared(authority.clone().into_inner()).ok();
14041398
}
14051399

14061400
// A :scheme is required, except CONNECT.

tests/h2-tests/tests/server.rs

-27
Original file line numberDiff line numberDiff line change
@@ -441,33 +441,6 @@ async fn push_request_between_data() {
441441
#[ignore]
442442
fn accept_with_pending_connections_after_socket_close() {}
443443

444-
#[tokio::test]
445-
async fn recv_invalid_authority() {
446-
h2_support::trace_init!();
447-
let (io, mut client) = mock::new();
448-
449-
let bad_auth = util::byte_str("not:a/good authority");
450-
let mut bad_headers: frame::Headers = frames::headers(1)
451-
.request("GET", "https://example.com/")
452-
.eos()
453-
.into();
454-
bad_headers.pseudo_mut().authority = Some(bad_auth);
455-
456-
let client = async move {
457-
let settings = client.assert_server_handshake().await;
458-
assert_default_settings!(settings);
459-
client.send_frame(bad_headers).await;
460-
client.recv_frame(frames::reset(1).protocol_error()).await;
461-
};
462-
463-
let srv = async move {
464-
let mut srv = server::handshake(io).await.expect("handshake");
465-
assert!(srv.next().await.is_none());
466-
};
467-
468-
join(client, srv).await;
469-
}
470-
471444
#[tokio::test]
472445
async fn recv_connection_header() {
473446
h2_support::trace_init!();

0 commit comments

Comments
 (0)