From: Michael Wallner Date: Mon, 4 Sep 2006 10:31:11 +0000 (+0000) Subject: - fix issues with ob_start("ob_gzhandler") X-Git-Tag: RELEASE_1_0_0RC1~1782 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=97db4007db9dce21521d18b1f7448df2f4d8b4d2;p=php - fix issues with ob_start("ob_gzhandler") - add tests --- diff --git a/ext/zlib/tests/ob_004.phpt b/ext/zlib/tests/ob_004.phpt new file mode 100644 index 0000000000..874fb8a685 --- /dev/null +++ b/ext/zlib/tests/ob_004.phpt @@ -0,0 +1,23 @@ +--TEST-- +ob_gzhandler +--SKIPIF-- + +--INI-- +zlib.output_compression=0 +--ENV-- +HTTP_ACCEPT_ENCODING=gzip +--FILE-- + +--EXPECTF-- +%s +Content-Encoding: gzip +Vary: Accept-Encoding +%s + +‹%s diff --git a/ext/zlib/tests/ob_005.phpt b/ext/zlib/tests/ob_005.phpt new file mode 100644 index 0000000000..12083d7289 --- /dev/null +++ b/ext/zlib/tests/ob_005.phpt @@ -0,0 +1,19 @@ +--TEST-- +ob_gzhandler +--SKIPIF-- + +--INI-- +zlib.output_compression=0 +--ENV-- +HTTP_ACCEPT_ENCODING=gzip +--FILE-- + +--EXPECTF-- +%shi diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index 8e20190b05..7e427da5f8 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -105,10 +105,11 @@ php_output_handler *php_zlib_output_handler_init(zval *handler_name, size_t chun { php_output_handler *h = NULL; - if (php_zlib_output_encoding(TSRMLS_C)) { - if ((h = php_output_handler_create_internal(handler_name, php_zlib_output_handler, chunk_size, flags TSRMLS_CC))) { - php_output_handler_set_context(h, ecalloc(1, sizeof(php_zlib_context)), php_zlib_output_handler_dtor TSRMLS_CC); - } + if (!ZLIBG(output_compression)) { + ZLIBG(output_compression) = chunk_size ? chunk_size : PHP_OUTPUT_HANDLER_DEFAULT_SIZE; + } + if ((h = php_output_handler_create_internal(handler_name, php_zlib_output_handler, chunk_size, flags TSRMLS_CC))) { + php_output_handler_set_context(h, ecalloc(1, sizeof(php_zlib_context)), php_zlib_output_handler_dtor TSRMLS_CC); } return h; @@ -119,7 +120,7 @@ php_output_handler *php_zlib_output_handler_init(zval *handler_name, size_t chun int php_zlib_output_handler(void **handler_context, php_output_context *output_context) { php_zlib_context *ctx = *(php_zlib_context **) handler_context; - int flags = Z_SYNC_FLUSH, status; + int flags = Z_SYNC_FLUSH; PHP_OUTPUT_TSRMLS(output_context); if (!php_zlib_output_encoding(TSRMLS_C)) { @@ -180,7 +181,7 @@ int php_zlib_output_handler(void **handler_context, php_output_context *output_c flags = Z_FULL_FLUSH; } - switch ((status = deflate(&ctx->Z, flags))) { + switch (deflate(&ctx->Z, flags)) { case Z_OK: if (flags == Z_FINISH) { deflateEnd(&ctx->Z); @@ -629,7 +630,7 @@ static PHP_INI_MH(OnUpdate_zlib_output_compression) { int status, int_value; char *ini_value; - + if (new_value == NULL) { return FAILURE; }