Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Copy link
Copy link
Closed
@ant-hill

Description

@ant-hill
Issue body actions

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);

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.