]> granicus.if.org Git - php/commitdiff
Move Content-Length: header handling from zlib.c to output.c
authorYasuo Ohgaki <yohgaki@php.net>
Thu, 2 May 2002 01:12:01 +0000 (01:12 +0000)
committerYasuo Ohgaki <yohgaki@php.net>
Thu, 2 May 2002 01:12:01 +0000 (01:12 +0000)
When output buffer is enabled and header can be sent, Content-Length:
header is added always from now on.

ext/zlib/zlib.c
main/output.c

index d109debea1cb77759710efbd0ea2f3301f044463..f69a570b0ca9b8ce9e74a814592cda7628db33dc 100644 (file)
 #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 @@ PHP_FUNCTION(ob_gzhandler)
 
                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 @@ static void php_gzip_output_handler(char *output, uint output_len, char **handle
        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 fcc70e6954cb22352458fe6ebc197e51f0af1d0a..5b41bd8bdfc719f6c9d1df0c488c6d1cfca050e9 100644 (file)
@@ -35,6 +35,18 @@ static void php_ob_append(const char *text, uint text_length TSRMLS_DC);
 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 @@ PHPAPI void php_end_ob_buffer(zend_bool send_buffer, zend_bool just_flush TSRMLS
                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;
                }
        }