jani Mon, 17 Aug 2009 17:30:32 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=287423
Log: - Fixed bug #49248 by fixing bug #48994 properly Bugs: http://bugs.php.net/49248 (Assigned) undefined reference to `zlib_globals' http://bugs.php.net/48994 (Closed) zlib.output_compression does not ouput HTTP headers when set to a string value Changed paths: U php/php-src/branches/PHP_5_2/ext/zlib/zlib.c U php/php-src/branches/PHP_5_2/main/SAPI.c U php/php-src/branches/PHP_5_3/ext/zlib/zlib.c U php/php-src/branches/PHP_5_3/main/SAPI.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-08-17 16:54:39 UTC (rev 287422) +++ php/php-src/branches/PHP_5_2/ext/zlib/zlib.c 2009-08-17 17:30:32 UTC (rev 287423) @@ -993,6 +993,19 @@ } 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"); } Modified: php/php-src/branches/PHP_5_2/main/SAPI.c =================================================================== --- php/php-src/branches/PHP_5_2/main/SAPI.c 2009-08-17 16:54:39 UTC (rev 287422) +++ php/php-src/branches/PHP_5_2/main/SAPI.c 2009-08-17 17:30:32 UTC (rev 287423) @@ -32,9 +32,6 @@ #if (HAVE_PCRE || HAVE_BUNDLED_PCRE) && !defined(COMPILE_DL_PCRE) #include "ext/pcre/php_pcre.h" #endif -#if HAVE_ZLIB -#include "ext/zlib/php_zlib.h" -#endif #ifdef ZTS #include "TSRM.h" #endif @@ -765,36 +762,6 @@ return SUCCESS; } -#if HAVE_ZLIB - /* Add output compression headers at this late stage in order to make - it possible to switch it off inside the script. */ - - if (ZLIBG(output_compression)) { - zval nm_zlib_get_coding_type; - zval *uf_result = NULL; - - ZVAL_STRINGL(&nm_zlib_get_coding_type, "zlib_get_coding_type", sizeof("zlib_get_coding_type") - 1, 0); - - if (call_user_function_ex(CG(function_table), NULL, &nm_zlib_get_coding_type, &uf_result, 0, NULL, 1, NULL TSRMLS_CC) != FAILURE && uf_result != NULL && Z_TYPE_P(uf_result) == IS_STRING) { - char buf[128]; - int len; - - assert(Z_STRVAL_P(uf_result) != NULL); - - len = slprintf(buf, sizeof(buf), "Content-Encoding: %s", Z_STRVAL_P(uf_result)); - if (len <= 0 || sapi_add_header(buf, len, 1) == FAILURE) { - return FAILURE; - } - if (sapi_add_header_ex("Vary: Accept-Encoding", sizeof("Vary: Accept-Encoding") - 1, 1, 0 TSRMLS_CC) == FAILURE) { - return FAILURE; - } - } - if (uf_result != NULL) { - zval_ptr_dtor(&uf_result); - } - } -#endif - /* Success-oriented. We set headers_sent to 1 here to avoid an infinite loop * in case of an error situation. */ Modified: php/php-src/branches/PHP_5_3/ext/zlib/zlib.c =================================================================== --- php/php-src/branches/PHP_5_3/ext/zlib/zlib.c 2009-08-17 16:54:39 UTC (rev 287422) +++ php/php-src/branches/PHP_5_3/ext/zlib/zlib.c 2009-08-17 17:30:32 UTC (rev 287423) @@ -1045,6 +1045,19 @@ } 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"); } Modified: php/php-src/branches/PHP_5_3/main/SAPI.c =================================================================== --- php/php-src/branches/PHP_5_3/main/SAPI.c 2009-08-17 16:54:39 UTC (rev 287422) +++ php/php-src/branches/PHP_5_3/main/SAPI.c 2009-08-17 17:30:32 UTC (rev 287423) @@ -32,9 +32,6 @@ #if (HAVE_PCRE || HAVE_BUNDLED_PCRE) && !defined(COMPILE_DL_PCRE) #include "ext/pcre/php_pcre.h" #endif -#if HAVE_ZLIB -#include "ext/zlib/php_zlib.h" -#endif #ifdef ZTS #include "TSRM.h" #endif @@ -790,36 +787,6 @@ return SUCCESS; } -#if HAVE_ZLIB - /* Add output compression headers at this late stage in order to make - it possible to switch it off inside the script. */ - - if (ZLIBG(output_compression)) { - zval nm_zlib_get_coding_type; - zval *uf_result = NULL; - - ZVAL_STRINGL(&nm_zlib_get_coding_type, "zlib_get_coding_type", sizeof("zlib_get_coding_type") - 1, 0); - - if (call_user_function_ex(CG(function_table), NULL, &nm_zlib_get_coding_type, &uf_result, 0, NULL, 1, NULL TSRMLS_CC) != FAILURE && uf_result != NULL && Z_TYPE_P(uf_result) == IS_STRING) { - char buf[128]; - int len; - - assert(Z_STRVAL_P(uf_result) != NULL); - - len = slprintf(buf, sizeof(buf), "Content-Encoding: %s", Z_STRVAL_P(uf_result)); - if (len <= 0 || sapi_add_header(buf, len, 1) == FAILURE) { - return FAILURE; - } - if (sapi_add_header_ex("Vary: Accept-Encoding", sizeof("Vary: Accept-Encoding") - 1, 1, 0 TSRMLS_CC) == FAILURE) { - return FAILURE; - } - } - if (uf_result != NULL) { - zval_ptr_dtor(&uf_result); - } - } -#endif - /* Success-oriented. We set headers_sent to 1 here to avoid an infinite loop * in case of an error situation. */
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php