From: Jason Greene Date: Wed, 29 Nov 2000 01:22:49 +0000 (+0000) Subject: Added the capability to specify a different HTTP Redirection response code X-Git-Tag: php-4.0.4RC3~34 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d8bc7084ee15fa94a7bbbce3a8fc019ad9dcb2f1;p=php Added the capability to specify a different HTTP Redirection response code before the Location Header. Ex. header("HTTP/1.1 307 Temporary Redirect"); header("Location: URL"); --- diff --git a/main/SAPI.c b/main/SAPI.c index 67bd8019de..eba50440dd 100644 --- a/main/SAPI.c +++ b/main/SAPI.c @@ -426,7 +426,11 @@ SAPI_API int sapi_add_header_ex(char *header_line, uint header_line_len, zend_bo efree(mimetype); SG(sapi_headers).send_default_content_type = 0; } else if (!STRCASECMP(header_line, "Location")) { - SG(sapi_headers).http_response_code = 302; /* redirect */ + if (SG(sapi_headers).http_response_code < 300 || + SG(sapi_headers).http_response_code > 307) { + /* Return a Found Redirect if one is not already specified */ + SG(sapi_headers).http_response_code = 302; + } } else if (!STRCASECMP(header_line, "WWW-Authenticate")) { /* HTTP Authentication */ SG(sapi_headers).http_response_code = 401; /* authentication-required */ }