Skip to content

Commit 7482820

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 7482820

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

src/server.rs

+15-8
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ use crate::{FlowControl, PingPong, RecvStream, SendStream};
123123
use bytes::{Buf, Bytes};
124124
use http::{HeaderMap, Method, Request, Response};
125125
use std::future::Future;
126+
use std::path::Path;
126127
use std::pin::Pin;
127128
use std::task::{Context, Poll};
128129
use std::time::Duration;
@@ -1393,14 +1394,20 @@ impl proto::Peer for Peer {
13931394
// A request translated from HTTP/1 must not include the :authority
13941395
// header
13951396
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-
})?);
1397+
// When connecting to a UNIX Domain Socket (UDS), then we might get a path for the
1398+
// authority field. If it's a local path and exists, then we do not error in that case
1399+
// and assume an UDS.
1400+
if !Path::new(authority.as_str()).exists() {
1401+
let maybe_authority =
1402+
uri::Authority::from_maybe_shared(authority.clone().into_inner());
1403+
parts.authority = Some(maybe_authority.or_else(|why| {
1404+
malformed!(
1405+
"malformed headers: malformed authority ({:?}): {}",
1406+
authority,
1407+
why,
1408+
)
1409+
})?);
1410+
}
14041411
}
14051412

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

0 commit comments

Comments
 (0)