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

Status always is 200 not matter the code set in the psr response #2

Closed
imefisto opened this issue Jun 13, 2021 · 0 comments
Closed

Comments

@imefisto
Copy link
Owner

If the status function is invoked on swoole response after calling the write function, no matter the code you've passed, the final status code will be 200.

swoole/swoole-src#4198 (comment)

To prevent this, the call to the status function in the following snippet should be moved before to the copyHeaders function call:

class ResponseMerger
{
    // ...
    
    public function toSwoole(ResponseInterface $psrResponse, Response $swooleResponse): Response
    {
        // Set here the status on swooleResponse 

        $this->copyHeaders($psrResponse, $swooleResponse);
        $this->copyBody($psrResponse, $swooleResponse);
        $swooleResponse->status($psrResponse->getStatusCode());

        return $swooleResponse;
    }

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

No branches or pull requests

1 participant