Hello all, I've cooked up a short patch for Bug 42362, and would
appreciate comments. The patch turns off zlib compression if there is no
output, to make zlib_compression play more nicely with 304s.
Cheers,
Edward
Index: ext/zlib/zlib.c
RCS file: /repository/php-src/ext/zlib/zlib.c,v
retrieving revision 1.183.2.6.2.8
diff -u -r1.183.2.6.2.8 zlib.c
--- ext/zlib/zlib.c 31 Dec 2008 11:17:47 -0000 1.183.2.6.2.8
+++ ext/zlib/zlib.c 17 Feb 2009 20:43:28 -0000
@@ -979,7 +979,7 @@
{
zend_bool do_start, do_end;
- if (!ZLIBG(output_compression)) {
- if (!ZLIBG(output_compression) || !output_len) {
*handled_output = NULL;
} else {
do_start = (mode &PHP_OUTPUT_HANDLER_START
? 1 : 0);
Edward Z. Yang wrote:
Hello all, I've cooked up a short paonetch for Bug 42362, and would
appreciate comments. The patch turns off zlib compression if there is no
output, to make zlib_compression play more nicely with 304s.
The previous patch is wrong (it doesn't handle the flush()
;flush(); case
well). Here's a better one, although it's 304 specific:
Index: ext/zlib/zlib.c
RCS file: /repository/php-src/ext/zlib/zlib.c,v
retrieving revision 1.183.2.6.2.8
diff -u -r1.183.2.6.2.8 zlib.c
--- ext/zlib/zlib.c 31 Dec 2008 11:17:47 -0000 1.183.2.6.2.8
+++ ext/zlib/zlib.c 17 Feb 2009 22:13:40 -0000
@@ -979,7 +979,7 @@
{
zend_bool do_start, do_end;
- if (!ZLIBG(output_compression)) {
- if (!ZLIBG(output_compression) || SG(sapi_headers).http_response_code
== 304) {
*handled_output = NULL;
} else {
do_start = (mode &PHP_OUTPUT_HANDLER_START
? 1 : 0);
Edward Z. Yang wrote:
The previous patch is wrong (it doesn't handle the
flush()
;flush(); case
well). Here's a better one, although it's 304 specific:
Bump?
CC'ed authors of zlib.c
Could this patch be applied to PHP_5_2 and further?
Index: ext/zlib/zlib.c
RCS file: /repository/php-src/ext/zlib/zlib.c,v
retrieving revision 1.183.2.6.2.8
diff -u -r1.183.2.6.2.8 zlib.c
--- ext/zlib/zlib.c 31 Dec 2008 11:17:47 -0000 1.183.2.6.2.8
+++ ext/zlib/zlib.c 17 Feb 2009 22:13:40 -0000
@@ -979,7 +979,7 @@
{
zend_bool do_start, do_end;
- if (!ZLIBG(output_compression)) {
- if (!ZLIBG(output_compression) || SG(sapi_headers).http_response_code
== 304) {
*handled_output = NULL;
} else {
do_start = (mode &PHP_OUTPUT_HANDLER_START
? 1 : 0);
Cheers,
Edward
bump
-----Original Message-----
From: news [mailto:news@ger.gmane.org] On Behalf Of Edward Z. Yang
Sent: 24 February 2009 7:38 am
To: internals@lists.php.net
Cc: rasmus@lerdorf.on.ca; sr@linux.de; zeev@zend.com; nicoletti@nns.ch
Subject: Re: [PHP-DEV] Don't compress empty output with zlib
CC'ed authors of zlib.c
Could this patch be applied to PHP_5_2 and further?
Index: ext/zlib/zlib.c
RCS file: /repository/php-src/ext/zlib/zlib.c,v
retrieving revision 1.183.2.6.2.8
diff -u -r1.183.2.6.2.8 zlib.c
--- ext/zlib/zlib.c 31 Dec 2008 11:17:47 -0000 1.183.2.6.2.8
+++ ext/zlib/zlib.c 17 Feb 2009 22:13:40 -0000
@@ -979,7 +979,7 @@
{
zend_bool do_start, do_end;
- if (!ZLIBG(output_compression)) {
- if (!ZLIBG(output_compression) ||
SG(sapi_headers).http_response_code
== 304) {
*handled_output = NULL;
} else {
do_start = (mode &PHP_OUTPUT_HANDLER_START
? 1 : 0);
Cheers,
Edward