summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYasuo Ohgaki <yohgaki@php.net>2002-05-02 01:12:01 +0000
committerYasuo Ohgaki <yohgaki@php.net>2002-05-02 01:12:01 +0000
commit43df0c78c051c87d4cca21fafb09f02526e19f8d (patch)
treea9831a76089b6d848d71ad0914b7df1bd8778639
parentf46c1527750f4aa9e307e9ce0623d94c25a784e6 (diff)
downloadphp-git-43df0c78c051c87d4cca21fafb09f02526e19f8d.tar.gz
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.
-rw-r--r--ext/zlib/zlib.c21
-rw-r--r--main/output.c13
2 files changed, 16 insertions, 18 deletions
diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c
index d109debea1..f69a570b0c 100644
--- a/ext/zlib/zlib.c
+++ b/ext/zlib/zlib.c
@@ -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 @@ 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);
- }
+ }
}
/* }}} */
diff --git a/main/output.c b/main/output.c
index fcc70e6954..5b41bd8bdf 100644
--- a/main/output.c
+++ b/main/output.c
@@ -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;
}
}