Skip to content

Commit 0447e60

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 0447e60

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/server.rs

Lines changed: 14 additions & 8 deletions
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,19 @@ 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 = uri::Authority::from_maybe_shared(authority.clone().into_inner());
1402+
parts.authority = Some(maybe_authority.or_else(|why| {
1403+
malformed!(
1404+
"malformed headers: malformed authority ({:?}): {}",
1405+
authority,
1406+
why,
1407+
)
1408+
})?);
1409+
}
14041410
}
14051411

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

0 commit comments

Comments
 (0)