-
Notifications
You must be signed in to change notification settings - Fork 308
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::from_parts to return SlashInPathMissing #229
base: master
Are you sure you want to change the base?
Conversation
If authority is given, but path is not empty and doesn't start with "/", return error.
Oh my, yea, that's definitely wrong! Thanks for filing this. I wonder, should perhaps |
According to the section 3 of the RFC mentioned above:
the "urn:example:animal:ferret:nose" is a valid URI with schema "urn" and path "example:animal:ferret:nose" with no leading "/". Taking into account that this is
allows creation of such URIs that can be used in this kind of html:
which kind of makes sense to support by a crate whose name is "http". OTOH, neither hyper client nor server would have any use for a URI whose schema is not HTTP or HTTPS and if schema is provided then path can be either empty or has to have a leading "/". |
tl;dr What I am saying is that it is up to your ambition whether you want to support generic URI or to be more hyper specific in which case a lot of code from https://github.com/hyperium/http/blob/master/src/uri/scheme.rs and this lines https://github.com/hyperium/http/blob/master/src/uri/mod.rs#L189-L193 can go away (unless I am missing something and there actually is a use case for relative references and generic URI in hyper) |
I'm not decided which makes more sense... @carllerche? |
I believe the goal of this Uri type is only to support cases from HTTP 1.x and 2.0. For 1.x, this would be the request line and for 2.0, it would be representing the related pseudo headers. I guess, the question is what is valid for HTTP 1.x, because 2.0 is pretty strict. |
In this case, at the very least, |
When running this code:
the intention would most likely be to print "http://www.example.com/my_path", but in reality it is "http://www.example.commy_path" (notice the missing slash).
Rust playground here: https://play.rust-lang.org/?gist=903f0d760c9b94b358a21540301c2a02&version=stable&mode=debug&edition=2015
This can lead into annoying bugs and furthermore is against the RFC3986 sections 3 and 3.3 where it states that: