Thanks to visit codestin.com
Credit goes to github.com

Skip to content

\Symfony\Component\HttpFoundation\Response HTTP/* header malformed on hhvm on several http status codes #16481

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

Closed
ant-hill opened this issue Nov 6, 2015 · 2 comments

Comments

@ant-hill
Copy link

ant-hill commented Nov 6, 2015

Version of symfony: 2.*
Step to reproduce:

        $resp = new \Symfony\Component\HttpFoundation\Response('test',\Symfony\Component\HttpFoundation\Response::HTTP_UNPROCESSABLE_ENTITY);
        $resp->headers->set('MyHeader','MyValue');
        $resp->send();

Result:

curl -vvv -XGET http://ololo-pew-pew/api/v1/performance/tick
[SKIPPED]
< HTTP/1.1 422
[SKIPPED]

Expected:

curl -vvv -XGET http://ololo-pew-pew/api/v1/performance/tick
[SKIPPED]
< HTTP/1.1 422 Unprocessable Entity
[SKIPPED]

This behaviour occurs due hhvm header implementation:
https://github.com/facebook/hhvm/blob/44b242ba185856a3e6661d8179039d8274d0d4a9/hphp/runtime/ext/std/ext_std_network.cpp#L284
https://github.com/facebook/hhvm/blob/4a3be43df46ea29b5d7860aaa524bd3ee8aaf4c8/hphp/runtime/server/transport.cpp#L521
https://github.com/facebook/hhvm/blob/f3fb59b8639668cc6ec26db56da350e04e2fe182/hphp/runtime/server/http-protocol.cpp#L940

hhvm rewrite HTTP response header on each call header() function if pass response code

I think that the simplest workaround is change:
https://github.com/symfony/symfony/blob/2.8/src/Symfony/Component/HttpFoundation/Response.php#L332
to

// headers
foreach ($this->headers->allPreserveCase() as $name => $values) {
    foreach ($values as $value) {
        header($name.': '.$value, false, $this->statusCode);
    }
}

// status
header(sprintf('HTTP/%s %s %s', $this->version, $this->statusCode, $this->statusText), true, $this->statusCode);
@nicolas-grekas
Copy link
Member

See #16669

nicolas-grekas added a commit that referenced this issue Nov 26, 2015
…ine (nicolas-grekas)

This PR was merged into the 2.3 branch.

Discussion
----------

[HttpFoundation] Workaround HHVM rewriting HTTP response line

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #16481, #9365
| License       | MIT
| Doc PR        | -

Commits
-------

5013f98 [HttpFoundation] Workaround HHVM rewriting HTTP response line
@javiereguiluz
Copy link
Member

Closing because this bug was fixed in #16669.

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

No branches or pull requests

5 participants