Bug #70273 [NEW]: header(): Setting the Location header will set a status code of 202 to 302.

From: Date: Fri, 14 Aug 2015 19:45:06 +0000
Subject: Bug #70273 [NEW]: header(): Setting the Location header will set a status code of 202 to 302.
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-195215@lists.php.net to get a copy of this message
From: jeff at nd4c dot com Operating system: Any PHP version: Irrelevant Package: HTTP related Bug Type: Bug Bug description:header(): Setting the Location header will set a status code of 202 to 302. Description: ------------ Setting the Location header will set a status code of 202 to 302. From the online documentation: (http://php.net/manual/en/function.header.php) ... The second special case is the "Location:" header. Not only does it send this header back to the browser, but it also returns a REDIRECT (302) status code to the browser unless the 201 or a 3xx status code has already been set. ... The auto redirect ignores status codes: 201 and 3xx, but it SHOULD also ignore status code: 202. Using the Location header for a 202 response is now the standard for a RESTful api. According to: http://restcookbook.com/Resources/asynchroneous-operations/ ...you can then issue at 202 (Accepted) response code. This informs the client that the request has been accepted and understood by the server, but the resource is not (yet) created. Send the temporary resource inside the Location header. Request: POST /blogs HTTP/1.1 <xml> blogdata </xml> Response: HTTP/1.1 202 Accepted Location: /queue/12345 ... Test script: --------------- header("HTTP/1.1 202 Accepted"); header('Location: /some/arbitrary/uri'); // This will change the status code to 302, but it shouldn't header('Location: /some/arbitrary/uri'); header("HTTP/1.1 202 Accepted", true, 202); // This works, always forcing the status code prevents the defaults redirect handling. Expected result: ---------------- Status code 202 should remain as 202 after a Location header is set. -- Edit bug report at https://bugs.php.net/bug.php?id=70273&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=70273&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=70273&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=70273&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=70273&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=70273&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=70273&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=70273&r=needscript Try newer version: https://bugs.php.net/fix.php?id=70273&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=70273&r=support Expected behavior: https://bugs.php.net/fix.php?id=70273&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=70273&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=70273&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=70273&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70273&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=70273&r=dst IIS Stability: https://bugs.php.net/fix.php?id=70273&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=70273&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=70273&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=70273&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=70273&r=mysqlcfg

« previous php.bugs (#195215) next »