Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uri does not parse valid URIs with empty authority portion #696

Open
dfawley opened this issue May 2, 2024 · 1 comment
Open

Uri does not parse valid URIs with empty authority portion #696

dfawley opened this issue May 2, 2024 · 1 comment

Comments

@dfawley
Copy link

dfawley commented May 2, 2024

Per RFC 3986, a valid URI may contain an empty authority (via an empty reg-name). However, it does not parse correctly by the Uri type:

https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=54db213feefae8e5b47294b4fcdbdad7

[src/main.rs:6:5] "file:///a/b/c".parse::<Uri>() = Err(
    InvalidUri(
        InvalidFormat,
    ),

Similarly, from_parts complains specifically that the authority is missing:

https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=0d31ed893d7f6cb8b37df6353eecfe8a

[src/main.rs:11:5] Uri::from_parts(parts) = Err(
    InvalidUriParts(
        InvalidUri(
            AuthorityMissing,
        ),
    ),

I could look into a change here, but note this fix would also be a breaking behavior change, and if any users are intentionally using this to enforce a non-empty authority, then they would be impacted.

cc @seanmonstar @LucioFranco - thanks!

@clarkmcc
Copy link

clarkmcc commented Jul 15, 2024

Would also like to have empty authorities in the URI. I can do it this way

http::Request::get("/foobar")

but I can't do this

Uri::builder()
    .scheme(Scheme::HTTPS)
    .authority(Authority::empty())
    .path_and_query("/foobar")
    .build()

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

No branches or pull requests

2 participants