]> granicus.if.org Git - php/commitdiff
Added the capability to specify a different HTTP Redirection response code
authorJason Greene <jason@php.net>
Wed, 29 Nov 2000 01:22:49 +0000 (01:22 +0000)
committerJason Greene <jason@php.net>
Wed, 29 Nov 2000 01:22:49 +0000 (01:22 +0000)
before the Location Header.

Ex. header("HTTP/1.1 307 Temporary Redirect");
    header("Location: URL");

main/SAPI.c

index 67bd8019de64482c1f96edd31df19c1955b8296d..eba50440dde7a59ef945fca937c87139849b00c5 100644 (file)
@@ -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 */
                        }