From 9fd708a313ac04120325ea52b0c75f2d61584a0a Mon Sep 17 00:00:00 2001 From: Zeev Suraski Date: Tue, 11 May 1999 18:36:35 +0000 Subject: [PATCH] Handle the Location: header centrally for all SAPI modules. --- main/SAPI.c | 21 ++++++++++++--------- mod_php3.c | 3 +-- 2 files changed, 13 insertions(+), 11 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; diff --git a/mod_php3.c b/mod_php3.c index 10a9262b00..924124b1ce 100644 --- a/mod_php3.c +++ b/mod_php3.c @@ -152,8 +152,6 @@ int sapi_apache_header_handler(sapi_header_struct *sapi_header, sapi_headers_str if (!strcasecmp(header_name, "Content-Type")) { r->content_type = pstrdup(r->pool, header_content); - } else if (!strcasecmp(header_name, "Location")) { - r->status = REDIRECT; } else { table_set(r->headers_out, header_name, header_content); } @@ -168,6 +166,7 @@ int sapi_apache_header_handler(sapi_header_struct *sapi_header, sapi_headers_str int sapi_apache_send_headers(sapi_headers_struct *sapi_headers SLS_DC) { + ((request_rec *) SG(server_context))->status = SG(sapi_headers).http_response_code; send_http_header((request_rec *) SG(server_context)); return SAPI_HEADER_SENT_SUCCESSFULLY; } -- 2.40.0