From cb38b78de1b9c61dd3b96e001b10f5abaface0a1 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Mon, 19 Aug 2024 13:17:16 +0200 Subject: fix hosts module for HTTP/2 --- src/modules/hosts.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/modules/hosts.rs') 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> + 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 -- cgit v1.2.3-70-g09d2