diff options
Diffstat (limited to 'ext/zlib/zlib.c')
-rw-r--r-- | ext/zlib/zlib.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index 8fe31422b..4d1b30a4f 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2009 The PHP Group | + | Copyright (c) 1997-2010 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -19,7 +19,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zlib.c 287423 2009-08-17 17:30:32Z jani $ */ +/* $Id: zlib.c 293036 2010-01-03 09:23:27Z sebastian $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -1046,16 +1046,23 @@ static void php_gzip_output_handler(char *output, uint output_len, char **handle do_start = (mode & PHP_OUTPUT_HANDLER_START ? 1 : 0); do_end = (mode & PHP_OUTPUT_HANDLER_END ? 1 : 0); - if (do_start && !SG(headers_sent) && !SG(request_info).no_headers) { - switch (ZLIBG(compression_coding)) { - case CODING_GZIP: - sapi_add_header_ex(ZEND_STRL("Content-Encoding: gzip"), 1, 1 TSRMLS_CC); - break; - case CODING_DEFLATE: - sapi_add_header_ex(ZEND_STRL("Content-Encoding: deflate"), 1, 1 TSRMLS_CC); - break; + if (do_start) { + if (!SG(headers_sent) && !SG(request_info).no_headers) { + switch (ZLIBG(compression_coding)) { + case CODING_GZIP: + sapi_add_header_ex(ZEND_STRL("Content-Encoding: gzip"), 1, 1 TSRMLS_CC); + break; + case CODING_DEFLATE: + sapi_add_header_ex(ZEND_STRL("Content-Encoding: deflate"), 1, 1 TSRMLS_CC); + break; + } + sapi_add_header_ex(ZEND_STRL("Vary: Accept-Encoding"), 1, 1 TSRMLS_CC); + } else { + /* Disable compression if headers can not be set (Fix for bug #49816) */ + ZLIBG(output_compression) = 0; + *handled_output = NULL; + return; } - sapi_add_header_ex(ZEND_STRL("Vary: Accept-Encoding"), 1, 1 TSRMLS_CC); } if (php_deflate_string(output, output_len, handled_output, handled_output_len, do_start, do_end TSRMLS_CC) != SUCCESS) { |