]> granicus.if.org Git - php/commitdiff
Handle the Location: header centrally for all SAPI modules.
authorZeev Suraski <zeev@php.net>
Tue, 11 May 1999 18:36:35 +0000 (18:36 +0000)
committerZeev Suraski <zeev@php.net>
Tue, 11 May 1999 18:36:35 +0000 (18:36 +0000)
main/SAPI.c
mod_php3.c

index b9f9e36e953dacae27a111e6bcba010e2c61fb11..b0315f28b9f752a08955e5f0fd997632eecd6a53 100644 (file)
@@ -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;
index 10a9262b000e86c70e1de4893137a16be6aff9cd..924124b1ce4075a932c6d085d0b0e51c3877db33 100644 (file)
@@ -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;
 }