Skip to content

Commit 613eb4f

Browse files
Do not require authority for UNIX domain sockets
Copy from hyperium#487 Thanks for the help from Sascha Grunert.
1 parent 88b0789 commit 613eb4f

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/server.rs

+14-8
Original file line numberDiff line numberDiff line change
@@ -1465,14 +1465,20 @@ impl proto::Peer for Peer {
14651465
// A request translated from HTTP/1 must not include the :authority
14661466
// header
14671467
if let Some(authority) = pseudo.authority {
1468-
let maybe_authority = uri::Authority::from_maybe_shared(authority.clone().into_inner());
1469-
parts.authority = Some(maybe_authority.or_else(|why| {
1470-
malformed!(
1471-
"malformed headers: malformed authority ({:?}): {}",
1472-
authority,
1473-
why,
1474-
)
1475-
})?);
1468+
// When connecting to a UNIX Domain Socket (UDS), then we might get a path for the
1469+
// authority field. If it's a local path and exists, then we do not error in that case
1470+
// and assume an UDS.
1471+
if !authority.is_empty() && !authority.ends_with(".sock") {
1472+
let maybe_authority =
1473+
uri::Authority::from_maybe_shared(authority.clone().into_inner());
1474+
parts.authority = Some(maybe_authority.or_else(|why| {
1475+
malformed!(
1476+
"malformed headers: malformed authority ({:?}): {}",
1477+
authority,
1478+
why,
1479+
)
1480+
})?);
1481+
}
14761482
}
14771483

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

0 commit comments

Comments
 (0)