From f0e844b64952500a0ab7dff11ba7bdf12f8abb65 Mon Sep 17 00:00:00 2001 From: patrick-immometrica Date: Thu, 5 Nov 2026 11:52:37 +0100 Subject: [PATCH] fix(uri): don't glue `*` onto the authority in Display A Uri with scheme, authority and path `*` (allowed since #843 for HTTP/2 OPTIONS requests) was formatted as `https://example.com*`, which parses back with an authority of `example.com*`. hyper writes the request target with Display when talking to a proxy, so this also went out on the wire. Per RFC 9112 section 3.2.4 the absolute-form of `OPTIONS *` has an empty path, so leave the `*` out when there is an authority. --- src/uri/builder.rs | 1 + src/uri/mod.rs | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/uri/builder.rs b/src/uri/builder.rs index 046a116a..b87b9d5a 100644 --- a/src/uri/builder.rs +++ b/src/uri/builder.rs @@ -257,5 +257,6 @@ mod tests { assert_eq!(uri.scheme(), Some(&Scheme::HTTPS)); assert_eq!(uri.host(), Some("example.com")); assert_eq!(uri.path(), "*"); + assert_eq!(uri.to_string(), "https://example.com"); } } diff --git a/src/uri/mod.rs b/src/uri/mod.rs index 9a551819..0f0b0156 100644 --- a/src/uri/mod.rs +++ b/src/uri/mod.rs @@ -1040,7 +1040,11 @@ impl fmt::Display for Uri { f.write_str(authority.as_str())?; } - f.write_str(self.path())?; + // RFC 9112 3.2.4: the absolute-form of an asterisk-form target has an + // empty path. Writing the `*` would make it part of the authority. + if self.authority().is_none() || self.path() != "*" { + f.write_str(self.path())?; + } if let Some(query) = self.query() { f.write_str("?")?;