-
-
Notifications
You must be signed in to change notification settings - Fork 571
Read getParsedBody() instead of getBody() when Request is ServerRequest #715
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
Conversation
98c558b to
fbe7ca4
Compare
vladar
left a comment
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 think we need a test for it? Then it is good to go!
|
Sure, if this is alright, I'll cover it. |
|
Looks good to me. @PowerKiKi will it work for you? |
|
Thank you for reaching out. I meant to come back to this earlier, but it slipped off my mind. I'll take some time to test this over the weekend and will get back to you. |
|
This work well for me. Thank you for taking the time fix this regression. However I still think that According to the spec,
Which is incorrect for our use-case. This lib does not send outgoing requests to other targets. But instead it does accept incoming requests and create a response for them. And that is exactly what
Also hardcoding "polymorphism" via This also introduce the new responsibility to this lib to be able to parse incoming request body. I would rather let that responsibility to dedicated libraries. (Yes, if this PR is accepted, it will allow to parse via another lib, but the point is to avoid setting expectation for this lib and instead be clear that parsing should be done by another lib). Finally, I fail to see why the original issue was not solved outside of this library by something as simple as: function processOutgoingRequest(\Psr\Http\Message\RequestInterface $outgoingRequest)
{
$incomingRequest = new \Laminas\Diactoros\ServerRequest();
$incomingRequest = $incomingRequest
->withBody($outgoingRequest->getBody());
$server = new StandardServer([/* ... */]);
foreach ($outgoingRequest->getHeaders() as $key => $value) {
$incomingRequest = $incomingRequest->withHeader($key, $value);
}
return $server->executePsrRequest($incomingRequest);
}tl;dr: i'm fine with merging this because it un-breaks things, but it is a sub-optimal solution |
|
TBH I don't see a reason why it shouldn't be able to parse all Requests. |
|
@PowerKiKi I think you are right given the description of those PSR request interfaces. But sadly simply reverting the original PR and using Thanks for surfacing this problem. |
|
@vladar definitely there's no doubt about those descriptions but I was wondering that allowing a wider API for lib consumers might be a good thing while I can prepare a revert and further cleanup if desired tho. |
This is where we disagree. Since this merged PR re-introduced support for ServerRequestInterface, then it means that RequestInterface does not contains everything we need. If I had to decide, I'd revert (in the next breaking or as a "minor" breaking), but I'll let that decision up to @vladar. Meanwhile I can update my libs to be compatible with |
Follows up #598