]> granicus.if.org Git - php/commitdiff
- fixed bug #40325 (Vary: header missing in gzip output handlers); no MFH
authorMichael Wallner <mike@php.net>
Wed, 18 Apr 2007 19:39:12 +0000 (19:39 +0000)
committerMichael Wallner <mike@php.net>
Wed, 18 Apr 2007 19:39:12 +0000 (19:39 +0000)
  [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

NEWS
ext/zlib/zlib.c

diff --git a/NEWS b/NEWS
index 4dae024bdfabf5a70e975515dce814a4457edce0..a1be27f842d28d6b5a64e42bd282a84b52d20af4 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -61,4 +61,4 @@ PHP                                                                        NEWS
 - 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)
index 5cb700a9ad94821de81c0e2e00c4c2fc85bcd087..392b7a95f44605ff40cafc185a7b01bdaac62625 100644 (file)
@@ -124,6 +124,19 @@ int php_zlib_output_handler(void **handler_context, php_output_context *output_c
        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 @@ int php_zlib_output_handler(void **handler_context, php_output_context *output_c
                                        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);
                }