jani Sun, 15 Nov 2009 00:13:19 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=290765
Log: - Temporary hack to fix bug #49816 (works fine in HEAD which has working output buffering..) Bug: http://bugs.php.net/49816 (Assigned) output corruption using flush Changed paths: U php/php-src/branches/PHP_5_2/ext/zlib/zlib.c U php/php-src/branches/PHP_5_3/ext/zlib/zlib.c Modified: php/php-src/branches/PHP_5_2/ext/zlib/zlib.c =================================================================== --- php/php-src/branches/PHP_5_2/ext/zlib/zlib.c 2009-11-14 23:29:50 UTC (rev 290764) +++ php/php-src/branches/PHP_5_2/ext/zlib/zlib.c 2009-11-15 00:13:19 UTC (rev 290765) @@ -994,16 +994,23 @@ 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) { Modified: php/php-src/branches/PHP_5_3/ext/zlib/zlib.c =================================================================== --- php/php-src/branches/PHP_5_3/ext/zlib/zlib.c 2009-11-14 23:29:50 UTC (rev 290764) +++ php/php-src/branches/PHP_5_3/ext/zlib/zlib.c 2009-11-15 00:13:19 UTC (rev 290765) @@ -1046,16 +1046,23 @@ 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) {
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php