Skip to content

Conversation

@kevinastone
Copy link

@kevinastone kevinastone commented Dec 16, 2018

Uri covers all the allowable values for the header value and provides type-safety.

@seanmonstar
Copy link
Member

Thanks for looking into this! Something that I wasn't certain about, and thus hadn't done this myself, is around the support of "locations" with ../ in them. That's a thing, right? I don't recall if Uri handles those...

@kevinastone
Copy link
Author

Let's add a test and find out.

@kevinastone
Copy link
Author

You're correct that fails to parse. Both url::Url and http::Uri don't support url-references.

hyperium/http#229 seems to indicate they don't intend to support references. I'll see if it's worth writing our own wrapper.

Some testing:

Url:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=d13520de40d3a56abcb10f50078c8466
Uri:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=91706357e953f6b5a2f4a390916bd661

Other languages:

kstone@kstone-mbp ~> python3
Python 3.7.1 (default, Nov  6 2018, 18:46:03) 
[Clang 10.0.0 (clang-1000.11.45.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from urllib.parse import urlparse
>>> urlparse("../something")
ParseResult(scheme='', netloc='', path='../something', params='', query='', fragment='')
kstone@kstone-mbp ~> irb
irb(main):001:0> URI("../something")
=> #<URI::Generic ../something>
irb(main):002:0> URI("../something").to_s
=> "../something"

@kevinastone kevinastone force-pushed the location branch 2 times, most recently from 8b3e9c7 to 259d350 Compare December 19, 2018 04:34
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.

2 participants