-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
[PSR-7] UriInterface: rootless path, delimiters, consistency #503
Conversation
@Tobion — thanks! My argument in #480 regarding the delimiters is this: the verbiage about delimiters exists to ensure that consumers know that they are receiving only the data for the component, without the delimiters. It was never about normalization; it was about ensuring consistency of return value, so that the consumer knows what they can do with it. I don't want them to assume anything; I want them to know what the value is. Other than those changes, I'm fine with this PR. But I think the delimiter specification is important for interface consumers. @nyamsprod and @simensen — what are your thoughts? |
* | ||
* The authority portion of the URI is: | ||
* The authority syntax of the URI is: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this should instead link to the ABNF in RFC 3986? https://tools.ietf.org/html/rfc3986#appendix-A
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can add @see https://tools.ietf.org/html/rfc3986#section-3.2
as we do in the other methods. Is that enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But I think having [user-info@]host[:port]
in the text is important for some users to understand it without following the link.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed with @Tobion — it's nice to have it in the text so that the consumer does not need to look it up, but an @see
annotation can be used to provide more information.
@weierophinney yes that's what I figured. I didn't remove the verbiage about delimiters in the getters, see diff. So users don't have to assume things. |
* If the query string is prefixed by "?", that character MUST be removed. | ||
* Additionally, the query string SHOULD be parseable by parse_str() in | ||
* order to be valid. | ||
* The query string SHOULD be parseable by parse_str() in order to be |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the purpose of this statement? Why must it be parseable by PHP's parse_str()? Shouldn't the only requirement be that it adheres to RFC 3986?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't add it and also wondered. It basically means that only a subset of query strings need to be supported. Because parse_str('=bar')
doesn't work but would be a valid query string AFAIK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is why it's a SHOULD and not a MUST. Typically, for PHP, if it's not parseable by parse_str()
, $_GET
, and thus getQueryParams()
, will be empty. However, since we are also targeting client-side usage, I think we can safely remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed the sentence
Once @Tobion has made the last few requested changes, this one is ready to merge! |
LGTM |
This is important for usability allowing simple comparison, e.g. `$request->getScheme() === 'http'`. Also clarified that __toString() returns a URI reference.
I added two commits that clarify some more things. Also added lowercase normalization of of scheme and host as we already agreed on in #480 |
* | ||
* This interface is meant to represent only URIs for use with HTTP requests, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that we have rootless path support as well, there is nothing that hinders UriInterface to be used generally. It's just that it doesn't define all possible methods to work with URIs, e.g. URI comparision etc. I hope I clarified that while also giving arguments why it's in the Http/Message namespace.
[PSR-7] UriInterface: rootless path, delimiters, consistency
$request->withPath('rootless/foo')
/
automaticallymailto:[email protected]
foo=bar
(without?
) is clear and also documented. this is task of the code that splits a URI into its components, e.g. the constructor of Uri. there is no method defined for that in PSR-7$request->withQuery('?foo=bar')->getQuery()
returnsfoo=bar
which makes no sense as I tried to explain in [PSR-7] Scheme delimiters clarification #480 (comment)%3Ffoo=bar
instead$request->getScheme() === 'http'