Re: cvs: php4 /ext/zlib zlib.c /main output.c

From: Date: Thu, 02 May 2002 03:58:29 +0000
Subject: Re: cvs: php4 /ext/zlib zlib.c /main output.c
References: 1  Groups: php.cvs 
Request: Send a blank email to php-cvs+get-11603@lists.php.net to get a copy of this message
Are you sure we know that this is the full length? What if someone buffered/flushed/buffered and flushed again? (I don't know the code too well I just want to make sure). Andi At 01:12 02/05/2002 +0000, Yasuo Ohgaki wrote:
yohgaki         Wed May  1 21:12:02 2002 EDT
Modified files:
    /php4/ext/zlib      zlib.c
    /php4/main  output.c
Log: Move Content-Length: header handling from zlib.c to output.c When output buffer is enabled and header can be sent, Content-Length: header is added always from now on. Index: php4/ext/zlib/zlib.c diff -u php4/ext/zlib/zlib.c:1.132 php4/ext/zlib/zlib.c:1.133 --- php4/ext/zlib/zlib.c:1.132 Sat Apr 27 19:37:17 2002
+++ php4/ext/zlib/zlib.c        Wed May  1 21:11:58 2002
@@ -18,7 +18,7 @@
    |          Jade Nicoletti <nicoletti@nns.ch>                           |
    +----------------------------------------------------------------------+
*/ -/* $Id: zlib.c,v 1.132 2002/04/27 23:37:17 sas Exp $ */ +/* $Id: zlib.c,v 1.133 2002/05/02 01:11:58 yohgaki Exp $ */ #define IS_EXT_MODULE #ifdef HAVE_CONFIG_H @@ -73,17 +73,6 @@ #endif #endif -#include "ext/standard/php_smart_str.h" - -#define ADD_CL_HEADER(xln) do
{                                                                \
-                       smart_str str = {0};                                                    \
- \
-                       smart_str_appends(&str, "Content-Length: ");    \
-                       smart_str_append_long(&str, xln);                               \
-                       smart_str_0(&str);                              \
-                       sapi_add_header(str.c, str.len, 0);                             \
-               } while(0)
-
 #define OS_CODE                        0x03 /* FIXME */
 #define CODING_GZIP            1
#define CODING_DEFLATE 2 @@ -938,9 +927,8 @@
                if (return_original) {
                        zval_dtor(return_value);
-               } else if (do_start && do_end)
-                       ADD_CL_HEADER(Z_STRLEN_P(return_value));
-
+               }
+
        } else {
                return_original = 1;
        }
@@ -963,10 +951,7 @@
        do_end = (mode & PHP_OUTPUT_HANDLER_END ? 1 : 0);
        if (php_deflate_string(output, output_len, handled_output, handled_output_len, ZLIBG(ob_gzip_coding), do_start, do_end, ZLIBG(output_compression_level) TSRMLS_CC)!=SUCCESS) {
                zend_error(E_ERROR, "Compression failed");
-       } else {
-               if (do_start && do_end)
-                  ADD_CL_HEADER(*handled_output_len);
-       }
+       }
} /* }}} */ Index: php4/main/output.c diff -u php4/main/output.c:1.89 php4/main/output.c:1.90
--- php4/main/output.c:1.89     Wed Apr 24 12:53:07 2002
+++ php4/main/output.c Wed May 1 21:12:01 2002 @@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
*/ -/* $Id: output.c,v 1.89 2002/04/24 16:53:07 stas Exp $ */ +/* $Id: output.c,v 1.90 2002/05/02 01:12:01 yohgaki Exp $ */ #include "php.h" #include "ext/standard/head.h" @@ -35,6 +35,18 @@ static void php_ob_prepend(const char *text, uint text_length); #endif +/* Add Content-Length: HTTP header */ +#include "ext/standard/php_smart_str.h" +#define ADD_CL_HEADER(xln) \
+{                                                      \
+       smart_str str = {0};                                                    \
+ \
+       smart_str_appends(&str, "Content-Length: ");    \
+       smart_str_append_long(&str, xln);                               \
+       smart_str_0(&str);              \
+       sapi_add_header(str.c, str.len, 0);                             \
+} + #ifdef ZTS int output_globals_id; @@ -199,6 +211,7 @@
                if (SG(headers_sent) && !SG(request_info).headers_only) {
                        OG(php_body_write) = php_ub_body_write_no_header;
                } else {
+                       ADD_CL_HEADER(OG(active_ob_buffer).text_length);
                        OG(php_body_write) = php_ub_body_write;
                }
        }
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.cvs (#11603) next »