-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
prevent PHP from magically setting a 302 header #9365
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
@@ -332,12 +332,12 @@ public function sendHeaders() | |||
} | |||
|
|||
// status | |||
header(sprintf('HTTP/%s %s %s', $this->version, $this->statusCode, $this->statusText)); | |||
header(sprintf('HTTP/%s %s %s', $this->version, $this->statusCode, $this->statusText), false, $this->statusCode); |
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'd rather keep true
for the replace argument (like it was before as true
is the default value.)
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.
ah my bad .. i thought the default was null
.. will fix this
👍 |
ok .. will look into writing a test case, though I am not sure if this is testable on the CLI .. |
i tried adding a unit test but as I feared it doesn't seem possible and it seems like we do not really have other tests for this either. I looked a bit on the web and found: but I could not get either of the proposes solutions in the various responses to work and return me all headers. |
@lsmith77 you can add a functional test for php >= 5.4 (with the build-in php server). |
This PR was merged into the master branch. Discussion ---------- prevent PHP from magically setting a 302 header | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | yes (for people relying on getting a magic 302 when setting a Location header) | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - this needs a test case .. but first let me know if you are ok with this change. see http://www.php.net/manual/en/function.header.php Commits ------- c140d4f prevent PHP from magically setting a 302 header, see http://www.php.net/manual/en/function.header.php
@fabpot this was waiting for the functional tests 👶 I guess that could be on a next PR |
@lsmith77 to test this you can define the header function during you testcase under the Symfony\Component\HttpFoundation namespace and php will use that one instead of the built in one. A bit hacky :) but has worked for me in a pinch |
would not be so useful in this case as we need to test the suppression of magic behavior of PHP. |
…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
this needs a test case .. but first let me know if you are ok with this change.
see http://www.php.net/manual/en/function.header.php