Skip to content

Commit ac28283

Browse files
committed
fix bug #65391
Unable to send vary header user-agent when ob_start('ob_gzhandler') is called
1 parent fc7fe62 commit ac28283

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ PHP NEWS
3636
. Fixed bug #62978 (Disallow possible SQL injections with pg_select()/pg_update()
3737
/pg_delete()/pg_insert()). (Yasuo)
3838

39+
- Zlib:
40+
. Fixed bug #65391 (Unable to send vary header user-agent when
41+
ob_start('ob_gzhandler') is called) (Mike)
42+
3943
?? ??? 2013, PHP 5.4.18
4044

4145
- Core:

ext/zlib/tests/bug65391.phpt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--TEST--
2+
Bug #65391 (Unable to send vary header user-agent when ob_start('ob_gzhandler') is called)
3+
--SKIPIF--
4+
<?php
5+
extension_loaded("zlib") or die("skip need zlib");
6+
?>
7+
--GET--
8+
dummy=1
9+
--FILE--
10+
<?php
11+
header("Vary: Cookie");
12+
ob_start("ob_gzhandler");
13+
14+
// run-tests cannot test for a multiple Vary header
15+
ob_flush();
16+
print_r(headers_list());
17+
18+
?>
19+
Done
20+
--EXPECTF--
21+
Array
22+
(
23+
[0] => X-Powered-By: PHP/%s
24+
[1] => Vary: Cookie
25+
[2] => Vary: Accept-Encoding
26+
)
27+
Done
28+

ext/zlib/zlib.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ static int php_zlib_output_handler(void **handler_context, php_output_context *o
190190
if ((output_context->op & PHP_OUTPUT_HANDLER_START)
191191
&& (output_context->op != (PHP_OUTPUT_HANDLER_START|PHP_OUTPUT_HANDLER_CLEAN|PHP_OUTPUT_HANDLER_FINAL))
192192
) {
193-
sapi_add_header_ex(ZEND_STRL("Vary: Accept-Encoding"), 1, 1 TSRMLS_CC);
193+
sapi_add_header_ex(ZEND_STRL("Vary: Accept-Encoding"), 1, 0 TSRMLS_CC);
194194
}
195195
return FAILURE;
196196
}
@@ -220,7 +220,7 @@ static int php_zlib_output_handler(void **handler_context, php_output_context *o
220220
deflateEnd(&ctx->Z);
221221
return FAILURE;
222222
}
223-
sapi_add_header_ex(ZEND_STRL("Vary: Accept-Encoding"), 1, 1 TSRMLS_CC);
223+
sapi_add_header_ex(ZEND_STRL("Vary: Accept-Encoding"), 1, 0 TSRMLS_CC);
224224
php_output_handler_hook(PHP_OUTPUT_HANDLER_HOOK_IMMUTABLE, NULL TSRMLS_CC);
225225
}
226226
}
@@ -478,7 +478,7 @@ static PHP_FUNCTION(ob_gzhandler)
478478
sapi_add_header_ex(ZEND_STRL("Content-Encoding: deflate"), 1, 1 TSRMLS_CC);
479479
break;
480480
}
481-
sapi_add_header_ex(ZEND_STRL("Vary: Accept-Encoding"), 1, 1 TSRMLS_CC);
481+
sapi_add_header_ex(ZEND_STRL("Vary: Accept-Encoding"), 1, 0 TSRMLS_CC);
482482
}
483483

484484
if (!ZLIBG(ob_gzhandler)) {

0 commit comments

Comments
 (0)