php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77155 Location header no longer coexists with status 201
Submitted: 2018-11-14 19:26 UTC Modified: 2021-07-25 04:22 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: marnick dot leau at gmail dot com Assigned: cmb (profile)
Status: No Feedback Package: CGI/CLI related
PHP Version: 7.2.12 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: marnick dot leau at gmail dot com
New email:
PHP Version: OS:

 

 [2018-11-14 19:26 UTC] marnick dot leau at gmail dot com
Description:
------------
In the selected version and some previous ones going back a few weeks or months (not sure which exact versions), a change was apparently made to the Location header mechanism.

Test script:
---------------
http_response_code(201);
header('HTTP/1.1 201 Created', true, 201);
header('Location: foobar', true, 201);
http_response_code(201);
header('HTTP/1.1 201 Created', true, 201);

Expected result:
----------------
It's supposed to be possible to set the Location header and have a status 3** OR 201. At the very least php's own docs confirm this: https://secure.php.net/manual/en/function.header.php

Actual result:
--------------
Setting the Location header results in a 302 no matter what I try to the contrary.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-11-15 13:19 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2018-11-15 13:19 UTC] cmb@php.net
header('Location: http://example.com/', true, 303);

works for me with latest PHP-7.2 and the built-in webserver. Which
SAPI do you use?
 [2018-11-15 16:31 UTC] marnick dot leau at gmail dot com
I use php in lighttpd, is fastcgi the answer you need?

Your example is 303, have you tried 201?

I suppose it could be a lighttpd issue too, but lighttpd's changelog doesn't mention anything like this either, and php has a history of being bossy about Location+status, so I started here...
 [2018-11-15 16:45 UTC] cmb@php.net
-Package: HTTP related +Package: Other web server
 [2018-11-15 16:45 UTC] cmb@php.net
> I use php in lighttpd, is fastcgi the answer you need?

Not quite.  What does php_sapi_name() return (likely either
cgi-fcgi or fpm-fcgi).
 [2018-11-16 15:39 UTC] marnick dot leau at gmail dot com
cgi-fcgi
 [2018-11-16 15:48 UTC] spam2 at rhsoft dot net
honestly that's why phpinfo() shows SAPI and so on to provide basic informations  in the initial report - keep in mind people need to duplicate issues and so in doubt need an as much as possible environment to debug
 [2018-11-16 15:49 UTC] cmb@php.net
-Status: Feedback +Status: Open -Package: Other web server +Package: CGI/CLI related -Assigned To: cmb +Assigned To:
 [2018-11-16 15:49 UTC] cmb@php.net
Thanks!
 [2018-11-16 15:54 UTC] marnick dot leau at gmail dot com
Didn't think of it, sorry. Do you want me to run that now or have you already been able to reproduce it now?
 [2021-07-14 13:59 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2021-07-14 13:59 UTC] cmb@php.net
I cannot reproduce this with PHP-7.4 and the given test script;
neither when running php-cgi stand-alone from the command line,
nor when running via IIS.  Either that issue has been fixed in the
meantime, or it is related to the Webserver.

If this is still an issue for you with any of the actively
supported PHP versions[1], please test running php-cgi from the
command line.

[1] <https://www.php.net/supported-versions.php>
 [2021-07-14 13:59 UTC] cmb@php.net
I cannot reproduce this with PHP-7.4 and the given test script;
neither when running php-cgi stand-alone from the command line,
nor when running via IIS.  Either that issue has been fixed in the
meantime, or it is related to the Webserver.

If this is still an issue for you with any of the actively
supported PHP versions[1], please test running php-cgi from the
command line.

[1] <https://www.php.net/supported-versions.php>
 [2021-07-25 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 05:01:27 2024 UTC