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

Optional API to convert to http::Uri #824

Open
Redfire75369 opened this issue Mar 7, 2023 · 3 comments
Open

Optional API to convert to http::Uri #824

Redfire75369 opened this issue Mar 7, 2023 · 3 comments

Comments

@Redfire75369
Copy link
Contributor

Rationale

The simplest way to convert from a url::Url to a http::Uri currently is to turn it into a string and then parse it again. It would be helpful if there was an API to do this conversion directly, instead of necessitating another round of parsing

Proposal

With a feature flag called http, the dependency http can be added.
When the http feature is active, a function can be exposed which does the conversion from url's internal structure to that of http::Uri's.

@valenting
Copy link
Collaborator

I'm not totally convinced this is something that belongs in the url crate.
I'd rather keep dependencies to a minimal, and even if this is behind a feature gate, it still needs CI testing.
I would suggest a crate that depends on both rust-url and http that uses Builder to create a new http uri from parts.

@Redfire75369
Copy link
Contributor Author

I understand your concerns, perhaps a Builder API for this crate may be more helpful then, so that the conversion could be done both ways relatively efficiently.

@Kinrany
Copy link

Kinrany commented Sep 13, 2023

Are URIs truly deprecated in some sense? The URL standard by WHATWG claims that a single algorithm is used for both and that they aim to deprecate URIs as a term in favor of URL, but I don't quite get how that could be possible when URIs are a superset of URLs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants