Skip to content

Commit 82ff467

Browse files
committed
Fixed bug #51269 (zlib.output_compression Overwrites Vary Header).
1 parent cf711f6 commit 82ff467

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

ext/zlib/tests/bug51269.phpt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
Bug #51269 (zlib.output_compression Overwrites Vary Header)
3+
--INI--
4+
zlib.output_compression=1
5+
--ENV--
6+
HTTP_ACCEPT_ENCODING=gzip
7+
--SKIPIF--
8+
<?php
9+
if (!extension_loaded("zlib")) die("skip zlib required");
10+
?>
11+
--FILE--
12+
<?php
13+
header('Vary: Cookie');
14+
echo 'foo';
15+
?>
16+
--EXPECTF--
17+
%s
18+
--EXPECTHEADERS--
19+
Vary: Cookie
20+
Content-Encoding: gzip
21+
Vary: Accept-Encoding

ext/zlib/zlib.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ static int php_zlib_output_handler(void **handler_context, php_output_context *o
102102
-Vary: $ HTTP_ACCEPT_ENCODING= ./sapi/cgi/php <<<'<?php ob_start("ob_gzhandler"); echo "foo\n"; ob_end_clean();'
103103
*/
104104
if (output_context->op != (PHP_OUTPUT_HANDLER_START|PHP_OUTPUT_HANDLER_CLEAN|PHP_OUTPUT_HANDLER_FINAL)) {
105-
sapi_add_header_ex(ZEND_STRL("Vary: Accept-Encoding"), 1, 1 TSRMLS_CC);
105+
sapi_add_header_ex(ZEND_STRL("Vary: Accept-Encoding"), 1, 0 TSRMLS_CC);
106106
}
107107
return FAILURE;
108108
}
@@ -196,7 +196,7 @@ static int php_zlib_output_handler(void **handler_context, php_output_context *o
196196
deflateEnd(&ctx->Z);
197197
return FAILURE;
198198
}
199-
sapi_add_header_ex(ZEND_STRL("Vary: Accept-Encoding"), 1, 1 TSRMLS_CC);
199+
sapi_add_header_ex(ZEND_STRL("Vary: Accept-Encoding"), 1, 0 TSRMLS_CC);
200200
php_output_handler_hook(PHP_OUTPUT_HANDLER_HOOK_IMMUTABLE, NULL TSRMLS_CC);
201201
}
202202

0 commit comments

Comments
 (0)