summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2024-08-19 13:17:16 +0200
committermetamuffin <metamuffin@disroot.org>2024-08-19 13:17:16 +0200
commitcb38b78de1b9c61dd3b96e001b10f5abaface0a1 (patch)
treef385a01a761775e11c307992e0e08ec43a3a6754
parent36a09fd6e452d2e6391a823a08787b5b17af7d08 (diff)
downloadgnix-cb38b78de1b9c61dd3b96e001b10f5abaface0a1.tar
gnix-cb38b78de1b9c61dd3b96e001b10f5abaface0a1.tar.bz2
gnix-cb38b78de1b9c61dd3b96e001b10f5abaface0a1.tar.zst
fix hosts module for HTTP/2
-rw-r--r--src/modules/hosts.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/modules/hosts.rs b/src/modules/hosts.rs
index 7ad7481..03a8b57 100644
--- a/src/modules/hosts.rs
+++ b/src/modules/hosts.rs
@@ -26,13 +26,15 @@ impl Node for Hosts {
request: NodeRequest,
) -> Pin<Box<dyn Future<Output = Result<NodeResponse, ServiceError>> + Send + Sync + 'a>> {
Box::pin(async move {
+ // use Host header but if missing like in HTTP/2 uses uri authority
let host = request
.headers()
.get(HOST)
.and_then(|e| e.to_str().ok())
+ .map(remove_port)
+ .or(request.uri().authority().map(|a| a.host()))
.ok_or(ServiceError::NoHost)?;
- let host = remove_port(host);
let node = self.0.get(host).ok_or(ServiceError::UnknownHost)?;
node.handle(context, request).await