note 30181 rejected from function.header by didou
| From: | didou@php.net | Date: | Sun, 25 May 2003 03:02:45 +0000 |
| Subject: | note 30181 rejected from function.header by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-48959@lists.php.net to get a copy of this message | ||
Note Submitter: Martin Rampersad (lastname@sympatico.ca)
----
(PHP 4.2.1, PHP 4.3.1)
If you use a header('Location:...') call in your code, PHP will _always_ force your
document's HTTP status code to be 302 if you don't already specify a 3XX code (unless you
use http_response_code, below). However, the HTTP Specification states that an "HTTP/1.1 201
Created" is a valid status code to pair with a "Location:..." header.
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.30
So, I upgraded to 4.3.1 but the problem remained, luckily the http_response_code option was added to
the function call. I used header('Location:...', TRUE, 201). Now my server responses
were getting generated properly.
Then, horror. Neither browser I used (IE 6 SP1, Mozilla/Phoenix) redirected to my location when I
returned a "201 Created" code.
I'm not sure if 201 was ever intended for use with automatic redirection (probably not), but
since my redirects don't work with it. I'm resigned to using "HTTP/1.1 302
Found" redirects.
I guess the only problem I see is PHP not letting a header('HTTP/1.1 201 Created') exist
with a header('Location:...') without some forcing.