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 a local UNIX domain socket path is
provided, where the authority contains the full path to the *.sock file
or is empty.

Signed-off-by: Sascha Grunert <sgrunert@suse.com>
  • Loading branch information
saschagrunert committed Oct 30, 2020
1 parent cbbdd30 commit 1f99ad3
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1395,14 +1395,20 @@ 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,
)
})?);
// When connecting to a UNIX Domain Socket (UDS), then we might get a path for the
// authority field. If it's a local path and exists, then we do not error in that case
// and assume an UDS.
if !authority.is_empty() && !authority.ends_with(".sock") {
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,
)
})?);
}
}

// A :scheme is required, except CONNECT.
Expand Down

0 comments on commit 1f99ad3

Please sign in to comment.