Skip to content

Commit

Permalink
Do not always require an authority
Browse files Browse the repository at this point in the history
This fixes connections where no authority is provide, for example when
using UNIX domain sockets.

Signed-off-by: Sascha Grunert <sgrunert@suse.com>
  • Loading branch information
saschagrunert committed Sep 16, 2020
1 parent a193237 commit 95a0d59
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 35 deletions.
10 changes: 2 additions & 8 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1393,14 +1393,8 @@ impl proto::Peer for Peer {
// A request translated from HTTP/1 must not include the :authority
// header
if let Some(authority) = pseudo.authority {
let maybe_authority = uri::Authority::from_maybe_shared(authority.clone().into_inner());
parts.authority = Some(maybe_authority.or_else(|why| {
malformed!(
"malformed headers: malformed authority ({:?}): {}",
authority,
why,
)
})?);
parts.authority =
uri::Authority::from_maybe_shared(authority.clone().into_inner()).ok();
}

// A :scheme is required, except CONNECT.
Expand Down
27 changes: 0 additions & 27 deletions tests/h2-tests/tests/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,33 +441,6 @@ async fn push_request_between_data() {
#[ignore]
fn accept_with_pending_connections_after_socket_close() {}

#[tokio::test]
async fn recv_invalid_authority() {
h2_support::trace_init!();
let (io, mut client) = mock::new();

let bad_auth = util::byte_str("not:a/good authority");
let mut bad_headers: frame::Headers = frames::headers(1)
.request("GET", "https://example.com/")
.eos()
.into();
bad_headers.pseudo_mut().authority = Some(bad_auth);

let client = async move {
let settings = client.assert_server_handshake().await;
assert_default_settings!(settings);
client.send_frame(bad_headers).await;
client.recv_frame(frames::reset(1).protocol_error()).await;
};

let srv = async move {
let mut srv = server::handshake(io).await.expect("handshake");
assert!(srv.next().await.is_none());
};

join(client, srv).await;
}

#[tokio::test]
async fn recv_connection_header() {
h2_support::trace_init!();
Expand Down

0 comments on commit 95a0d59

Please sign in to comment.