From 1f99ad3217fe437d2986fd86f0ba1c36952b7dd4 Mon Sep 17 00:00:00 2001 From: Sascha Grunert Date: Wed, 16 Sep 2020 15:22:25 +0200 Subject: [PATCH] Do not always require an authority 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 --- src/server.rs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/server.rs b/src/server.rs index 32433121a..8bf8f178c 100644 --- a/src/server.rs +++ b/src/server.rs @@ -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.