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

Add host_port and request_uir methods #421

Closed
wants to merge 2 commits into from
Closed

Conversation

@mina86
Copy link

mina86 commented Dec 31, 2017

host_port and request_uri methods are useful when dealing with HTTP requests. host_port is what needs to be sent in Host header while request_uri is what needs to be sent in the request line.


This change is Reviewable

mina86 added 2 commits Dec 31, 2017
When constructing HTTP requets path with the query string must be sent
to the server.  If customer of Url’s object needs to obtain that string
they have to construct it by themselves and if query string is present
in the URL allocation of a new String is necessary.

Add a method which constructs the request UIR and returns reference to
internal serialised storage avoiding the necessity to allocate a new
String.
HTTP Host header must include port number if that port does not
correspond to the defalut port for given scheme¹.  Introduce
a method which returns such host-port string without the need
to allocate a new String object.

¹ https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.23
@SimonSapin
Copy link
Member

SimonSapin commented Dec 31, 2017

Aren’t these methods equivalent to &url[Position::BeforeHost..Position::AfterPort] and &url[Position::BeforePath..Position::AfterQuery] respectively? Position exists specifically to enable all kinds of slicing without adding lots of ad-hoc methods.

@mina86
Copy link
Author

mina86 commented Dec 31, 2017

Ha! Yes, I missed those in the documentation. host_port is not exactly equivalent to &url[Position::BeforeHost..Position::AfterPort] since it checks whether port is the default, but it’s close enough.

@mina86 mina86 closed this Dec 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.