summaryrefslogtreecommitdiff
path: root/main/SAPI.c
diff options
context:
space:
mode:
authorZeev Suraski <zeev@php.net>1999-05-11 18:36:35 +0000
committerZeev Suraski <zeev@php.net>1999-05-11 18:36:35 +0000
commit9fd708a313ac04120325ea52b0c75f2d61584a0a (patch)
treed0a26b04adcfecb9c5bd0e76d06bdb086634418a /main/SAPI.c
parent473d1d7cf13f7cd76a2d515fbde62694c2f504fd (diff)
downloadphp-git-9fd708a313ac04120325ea52b0c75f2d61584a0a.tar.gz
Handle the Location: header centrally for all SAPI modules.
Diffstat (limited to 'main/SAPI.c')
-rw-r--r--main/SAPI.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/main/SAPI.c b/main/SAPI.c
index b9f9e36e95..b0315f28b9 100644
--- a/main/SAPI.c
+++ b/main/SAPI.c
@@ -121,6 +121,7 @@ SAPI_API int sapi_add_header(char *header_line, uint header_line_len)
{
int retval;
sapi_header_struct sapi_header;
+ char *colon_offset;
SLS_FETCH();
if (SG(headers_sent)) {
@@ -132,6 +133,17 @@ SAPI_API int sapi_add_header(char *header_line, uint header_line_len)
sapi_header.header = header_line;
sapi_header.header_len = header_line_len;
+ colon_offset = strchr(header_line, ':');
+ if (colon_offset) {
+ *colon_offset = 0;
+ if (!STRCASECMP(header_line, "Content-Type")) {
+ SG(sapi_headers).send_default_content_type = 0;
+ } else if (!STRCASECMP(header_line, "Location")) {
+ SG(sapi_headers).http_response_code = 302; /* redirect */
+ }
+ *colon_offset = ':';
+ }
+
if (sapi_module.header_handler) {
retval = sapi_module.header_handler(&sapi_header, &SG(sapi_headers) SLS_CC);
} else {
@@ -142,15 +154,6 @@ SAPI_API int sapi_add_header(char *header_line, uint header_line_len)
zend_llist_clean(&SG(sapi_headers).headers);
}
if (retval & SAPI_HEADER_ADD) {
- char *colon_offset = strchr(header_line, ':');
-
- if (colon_offset) {
- *colon_offset = 0;
- if (!STRCASECMP(header_line, "Content-Type")) {
- SG(sapi_headers).send_default_content_type = 0;
- }
- *colon_offset = ':';
- }
zend_llist_add_element(&SG(sapi_headers).headers, (void *) &sapi_header);
}
return SUCCESS;