diff options
Diffstat (limited to 'ext/zlib/zlib.c')
-rw-r--r-- | ext/zlib/zlib.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index a21c00d1e..8fe31422b 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -19,7 +19,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zlib.c,v 1.183.2.6.2.5.2.14 2009/05/28 10:15:14 lbarnaud Exp $ */ +/* $Id: zlib.c 287423 2009-08-17 17:30:32Z jani $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -1045,6 +1045,19 @@ static void php_gzip_output_handler(char *output, uint output_len, char **handle } else { 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; + } + 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) { zend_error(E_ERROR, "Compression failed"); } |