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

withRequestTarget() accepts string only #78

Closed
wants to merge 1 commit into from
Closed

withRequestTarget() accepts string only #78

wants to merge 1 commit into from

Conversation

BenMorel
Copy link

As far as I can see, withRequestTarget() only accepts a string.

Copy link
Contributor

@localheinz localheinz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@BenMorel
Copy link
Author

Anyone..?

@weierophinney
Copy link
Contributor

weierophinney commented Feb 13, 2017

Requires an errata vote. One reason why it allows non-strings is to potentially allow passing a UriInterface, which can be cast to a string in order to obtain the request target.

As such, narrowing the scope has the potential to break existing implementations and/or consumers.

@sharifzadesina
Copy link

sharifzadesina commented Feb 13, 2017

@weierophinney mixed means we can pass an array, a resource and etc... how people can know the mixed means string|UriInterface? as I have seen all psr-7 implementations are just support string.

@tehransenf
Copy link

perfect good post
thanks a lot

@AeonDigital
Copy link

I'm doing my own implementation of "RequestInterface" and am in doubt about how the "withRequestTarget" and "withUri" methods should work relative to their respective values ​​since:

If I use "withRequestTarget" passing as an argument a value that is totally different from the information that is contained in the respective "uri" object (especially with regards to the results of the "getPath" and "getQuery" methods) will result in a new "RequestInterface" instance where these values ​​do not match.

Is this supposed to be the case?

I know that the "requestTarget" is more complex than the simple join of "getPath" and "getQuery" but I would like to resolve this question in particular because I noticed that implementation made by the slim framework (https://github.com/slimphp/Slim-Http/blob/master/src/Request.php) uses the "getPath" and "getQuery" methods to form the "requestTarget" value, which seems to me to be a direct correlation between these values and I think that perhaps this correlation is at some level necessary for the purposes of the classes that implement the "RequestInterface"

@weierophinney
Copy link
Contributor

@AeonDigital Please do not hijack an existing pull request to ask unrelated questions.

To answer you, however: if a request target is provided to the request instance, that value should be used instead of the composed UriInterface for purposes of generating the request target in the request line.

If no request target is set, then the default, per RFC 7230 section 2.7 is to use origin-form, which is the path + query parameters (if any exist).

@Art4 Art4 mentioned this pull request Aug 28, 2023
@Art4
Copy link

Art4 commented Aug 28, 2023

This issue is resolved by #94.

@BenMorel
Copy link
Author

@weierophinney Good!

I can see that it has finally been restricted to string though?

@weierophinney
Copy link
Contributor

@BenMorel Correct. The spec uses RFC 7230 as a guide here, and the withRequestTarget() method is supposed to mirror getRequestTarget(), which specifies a string return value. The point of the method is to allow providing an replacement/alternative for what would normally be auto-discovered from the composed URI instance, and such values will always be strings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
7 participants