lbarnaud                Thu Nov 13 13:41:08 2008 UTC

  Modified files:              (Branch: PHP_5_3)
    /php-src/sapi/apache2filter sapi_apache2.c 
    /php-src/sapi/apache_hooks  mod_php5.c 
  Log:
  Updated header_handler in apache2filter and apache_hooks
  
  
http://cvs.php.net/viewvc.cgi/php-src/sapi/apache2filter/sapi_apache2.c?r1=1.136.2.2.2.8.2.4&r2=1.136.2.2.2.8.2.5&diff_format=u
Index: php-src/sapi/apache2filter/sapi_apache2.c
diff -u php-src/sapi/apache2filter/sapi_apache2.c:1.136.2.2.2.8.2.4 
php-src/sapi/apache2filter/sapi_apache2.c:1.136.2.2.2.8.2.5
--- php-src/sapi/apache2filter/sapi_apache2.c:1.136.2.2.2.8.2.4 Sun Aug  3 
12:15:55 2008
+++ php-src/sapi/apache2filter/sapi_apache2.c   Thu Nov 13 13:41:07 2008
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: sapi_apache2.c,v 1.136.2.2.2.8.2.4 2008/08/03 12:15:55 jani Exp $ */
+/* $Id: sapi_apache2.c,v 1.136.2.2.2.8.2.5 2008/11/13 13:41:07 lbarnaud Exp $ 
*/
 
 #include <fcntl.h>
 
@@ -91,7 +91,7 @@
 }
 
 static int
-php_apache_sapi_header_handler(sapi_header_struct *sapi_header, 
sapi_headers_struct *sapi_headers TSRMLS_DC)
+php_apache_sapi_header_handler(sapi_header_struct *sapi_header, 
sapi_header_op_enum op, sapi_headers_struct *sapi_headers TSRMLS_DC)
 {
        php_struct *ctx;
        ap_filter_t *f;
@@ -100,29 +100,44 @@
        ctx = SG(server_context);
        f = ctx->r->output_filters;
 
-       val = strchr(sapi_header->header, ':');
+       switch(op) {
+               case SAPI_HEADER_DELETE:
+                       apr_table_unset(ctx->r->headers_out, 
sapi_header->header);
+                       return 0;
+
+               case SAPI_HEADER_DELETE_ALL:
+                       apr_table_clear(ctx->r->headers_out);
+                       return 0;
+
+               case SAPI_HEADER_ADD:
+               case SAPI_HEADER_REPLACE:
+                       val = strchr(sapi_header->header, ':');
+
+                       if (!val) {
+                               sapi_free_header(sapi_header);
+                               return 0;
+                       }
+                       ptr = val;
+
+                       *val = '\0';
+                       
+                       do {
+                               val++;
+                       } while (*val == ' ');
+
+                       if (!strcasecmp(sapi_header->header, "content-type"))
+                               ctx->r->content_type = 
apr_pstrdup(ctx->r->pool, val);
+                       else if (op == SAPI_HEADER_REPLACE)
+                               apr_table_set(ctx->r->headers_out, 
sapi_header->header, val);
+                       else
+                               apr_table_add(ctx->r->headers_out, 
sapi_header->header, val);
+                       
+                       *ptr = ':';
+                       return SAPI_HEADER_ADD;
 
-       if (!val) {
-               sapi_free_header(sapi_header);
-               return 0;
+               default:
+                       return 0;
        }
-       ptr = val;
-
-       *val = '\0';
-       
-       do {
-               val++;
-       } while (*val == ' ');
-
-       if (!strcasecmp(sapi_header->header, "content-type"))
-               ctx->r->content_type = apr_pstrdup(ctx->r->pool, val);
-       else if (sapi_header->replace)
-               apr_table_set(ctx->r->headers_out, sapi_header->header, val);
-       else
-               apr_table_add(ctx->r->headers_out, sapi_header->header, val);
-       
-       *ptr = ':';
-       return SAPI_HEADER_ADD;
 }
 
 static int
http://cvs.php.net/viewvc.cgi/php-src/sapi/apache_hooks/mod_php5.c?r1=1.11.2.1.2.5.2.3&r2=1.11.2.1.2.5.2.4&diff_format=u
Index: php-src/sapi/apache_hooks/mod_php5.c
diff -u php-src/sapi/apache_hooks/mod_php5.c:1.11.2.1.2.5.2.3 
php-src/sapi/apache_hooks/mod_php5.c:1.11.2.1.2.5.2.4
--- php-src/sapi/apache_hooks/mod_php5.c:1.11.2.1.2.5.2.3       Tue Mar 18 
22:23:20 2008
+++ php-src/sapi/apache_hooks/mod_php5.c        Thu Nov 13 13:41:08 2008
@@ -17,7 +17,7 @@
    | PHP 4.0 patches by Zeev Suraski <[EMAIL PROTECTED]>                       
                  |
    +----------------------------------------------------------------------+
  */
-/* $Id: mod_php5.c,v 1.11.2.1.2.5.2.3 2008/03/18 22:23:20 rasmus Exp $ */
+/* $Id: mod_php5.c,v 1.11.2.1.2.5.2.4 2008/11/13 13:41:08 lbarnaud Exp $ */
 
 #include "php_apache_http.h"
 
@@ -34,7 +34,7 @@
 static void php_restore_umask(void);
 static int sapi_apache_read_post(char *buffer, uint count_bytes TSRMLS_DC);
 static char *sapi_apache_read_cookies(TSRMLS_D);
-static int sapi_apache_header_handler(sapi_header_struct *sapi_header, 
sapi_headers_struct *sapi_headers TSRMLS_DC);
+static int sapi_apache_header_handler(sapi_header_struct *sapi_header, 
sapi_header_op_enum op, sapi_headers_struct *sapi_headers TSRMLS_DC);
 static int sapi_apache_send_headers(sapi_headers_struct *sapi_headers 
TSRMLS_DC);
 static int send_php(request_rec *r, int display_source_mode, char *filename);
 static int send_parsed_php(request_rec * r);
@@ -308,35 +308,54 @@
 
 /* {{{ sapi_apache_header_handler
  */
-static int sapi_apache_header_handler(sapi_header_struct *sapi_header, 
sapi_headers_struct *sapi_headers TSRMLS_DC)
+static int sapi_apache_header_handler(sapi_header_struct *sapi_header, 
sapi_header_op_enum op, sapi_headers_struct *sapi_headers TSRMLS_DC)
 {
        char *header_name, *header_content, *p;
        request_rec *r = (request_rec *) SG(server_context);
-
-       header_name = sapi_header->header;
-
-       header_content = p = strchr(header_name, ':');
-       if (!p) {
-               efree(sapi_header->header);
+       if(!r) {
                return 0;
        }
 
-       *p = 0;
-       do {
-               header_content++;
-       } while (*header_content==' ');
-
-       if (!strcasecmp(header_name, "Content-Type")) {
-               r->content_type = pstrdup(r->pool, header_content);
-       } else if (!strcasecmp(header_name, "Set-Cookie")) {
-               table_add(r->headers_out, header_name, header_content);
-       } else {
-               table_set(r->headers_out, header_name, header_content);
-       }
+       switch(op) {
+               case SAPI_HEADER_DELETE_ALL:
+                       clear_table(r->headers_out);
+                       return 0;
+
+               case SAPI_HEADER_DELETE:
+                       table_unset(r->headers_out, sapi_header->header);
+                       return 0;
+
+               case SAPI_HEADER_ADD:
+               case SAPI_HEADER_REPLACE:
+                       header_name = sapi_header->header;
+
+                       header_content = p = strchr(header_name, ':');
+                       if (!p) {
+                               return 0;
+                       }
 
-       *p = ':';  /* a well behaved header handler shouldn't change its 
original arguments */
+                       *p = 0;
+                       do {
+                               header_content++;
+                       } while (*header_content==' ');
+
+                       if (!strcasecmp(header_name, "Content-Type")) {
+                               r->content_type = pstrdup(r->pool, 
header_content);
+                       } else if (!strcasecmp(header_name, "Set-Cookie")) {
+                               table_add(r->headers_out, header_name, 
header_content);
+                       } else if (op == SAPI_HEADER_REPLACE) {
+                               table_set(r->headers_out, header_name, 
header_content);
+                       } else {
+                               table_add(r->headers_out, header_name, 
header_content);
+                       }
+
+                       *p = ':';  /* a well behaved header handler shouldn't 
change its original arguments */
+
+                       return SAPI_HEADER_ADD;
 
-       return SAPI_HEADER_ADD;
+               default:
+                       return 0;
+       }
 }
 /* }}} */
 



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to