[PSR-7] UriInterface: rootless path, delimiters, consistency#503
[PSR-7] UriInterface: rootless path, delimiters, consistency#503pmjones merged 3 commits intophp-fig:masterfrom Tobion:rootless-path
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? |
proposed/http-message.md
Outdated
There was a problem hiding this comment.
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.
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.
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.
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. |
proposed/http-message.md
Outdated
There was a problem hiding this comment.
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.
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.
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.
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 |
There was a problem hiding this comment.
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:tobias@example.orgfoo=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=barwhich makes no sense as I tried to explain in [PSR-7] Scheme delimiters clarification #480 (comment)%3Ffoo=barinstead$request->getScheme() === 'http'