Skip to content

fix(uri): parse uppercase http/https as standard schemes - #883

Open
patrick-immometrica wants to merge 1 commit into
hyperium:masterfrom
patrick-immometrica:fix-scheme-case
Open

patrick-immometrica wants to merge 1 commit into
hyperium:masterfrom
patrick-immometrica:fix-scheme-case

Conversation

@patrick-immometrica

Copy link
Copy Markdown

Scheme::from_str("HTTP") returns an Other scheme instead of the standard one. The case-insensitive compare from #485 only applies between two Other schemes, so the parsed value is never equal to Scheme::HTTP. It also hashes differently, and as_str() returns "HTTP". Parsing a full Uri already lowercases the scheme, so only the standalone parse is affected:

let s: Scheme = "HTTP".parse().unwrap();
assert_eq!(s.as_str(), "http"); // fails, "HTTP"

parse_exact now matches http/https with eq_ignore_ascii_case. RFC 3986 3.1 says schemes are case-insensitive, and this is the scheme part of #46.

The new test fails on master with

assertion `left == right` failed
  left: "HTTP"
 right: "http"

and passes with the change.

Scheme::from_str("HTTP") produced Scheme2::Other, which is not equal to
Scheme::HTTP and hashes differently, while parsing a full Uri lowercases
the scheme and gets Scheme::HTTP. Match the two standard schemes
case-insensitively so both paths agree.
@patrick-immometrica
patrick-immometrica marked this pull request as ready for review November 5, 2026 11:07

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant