mike Wed Apr 18 19:39:12 2007 UTC
Modified files:
/php-src/ext/zlib zlib.c
/php-src NEWS
Log:
- fixed bug #40325 (Vary: header missing in gzip output handlers); no MFH
[DOC] since PHP 6 a Vary header will be sent without regards to whether
the negotiation was successful or not and unless the complete
output buffer gets discarded
http://cvs.php.net/viewvc.cgi/php-src/ext/zlib/zlib.c?r1=1.214&r2=1.215&diff_format=u
Index: php-src/ext/zlib/zlib.c
diff -u php-src/ext/zlib/zlib.c:1.214 php-src/ext/zlib/zlib.c:1.215
--- php-src/ext/zlib/zlib.c:1.214 Fri Feb 2 17:11:10 2007
+++ php-src/ext/zlib/zlib.c Wed Apr 18 19:39:12 2007
@@ -20,7 +20,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zlib.c,v 1.214 2007/02/02 17:11:10 mike Exp $ */
+/* $Id: zlib.c,v 1.215 2007/04/18 19:39:12 mike Exp $ */
#ifdef HAVE_CONFIG_H
# include "config.h"
@@ -124,6 +124,19 @@
PHP_OUTPUT_TSRMLS(output_context);
if (!php_zlib_output_encoding(TSRMLS_C)) {
+ /* "Vary: Accept-Encoding" header sent along uncompressed
content breaks caching in MSIE,
+ so let's just send it with successfully compressed
content or unless the complete
+ buffer gets discarded, see http://bugs.php.net/40325;
+
+ Test as follows:
+ +Vary: $ HTTP_ACCEPT_ENCODING=gzip ./sapi/cgi/php
<<<'<?php ob_start("ob_gzhandler"); echo "foo\n";'
+ +Vary: $ HTTP_ACCEPT_ENCODING= ./sapi/cgi/php <<<'<?php
ob_start("ob_gzhandler"); echo "foo\n";'
+ -Vary: $ HTTP_ACCEPT_ENCODING=gzip ./sapi/cgi/php
<<<'<?php ob_start("ob_gzhandler"); echo "foo\n"; ob_end_clean();'
+ -Vary: $ HTTP_ACCEPT_ENCODING= ./sapi/cgi/php <<<'<?php
ob_start("ob_gzhandler"); echo "foo\n"; ob_end_clean();'
+ */
+ if (output_context->op !=
(PHP_OUTPUT_HANDLER_START|PHP_OUTPUT_HANDLER_CLEAN|PHP_OUTPUT_HANDLER_FINAL)) {
+ sapi_add_header_ex(ZEND_STRL("Vary: Accept-Encoding"),
1, 1 TSRMLS_CC);
+ }
return FAILURE;
}
@@ -218,8 +231,6 @@
deflateEnd(&ctx->Z);
return FAILURE;
}
- /* "Vary: Accept-Encoding" header sent along
uncompressed content breaks caching in MSIE,
- so let's just send it with successfully compressed
content, see http://bugs.php.net/40325 */
sapi_add_header_ex(ZEND_STRL("Vary: Accept-Encoding"),
1, 1 TSRMLS_CC);
php_output_handler_hook(PHP_OUTPUT_HANDLER_HOOK_IMMUTABLE, NULL TSRMLS_CC);
}
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2144&r2=1.2145&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2144 php-src/NEWS:1.2145
--- php-src/NEWS:1.2144 Tue Apr 3 06:56:39 2007
+++ php-src/NEWS Wed Apr 18 19:39:12 2007
@@ -61,4 +61,4 @@
- Added str_getcsv() function. (Sara)
- Added ext/hash support to ext/session's ID generator. (Sara)
-
+- Fixed bug #40325 (Vary: header missing in gzip output handlers). (Mike)