We've run into some trouble with output compression, specifically when using
PHP to generate PDF's, and send them directly to the browser with an overridden
mime-type. It appears as though the browser support for this is rather lame;
even recent versions of Netscape hand Acrobat the compressed version of the
PDF, and Acrobat chokes, really badly. Some relatively recent versions of IE
also have problems dealing with compressed non-HTML content.

So, we really want to disable output compression when we are serving anything
but HTML/text. Easy enough. We simply wrap calls to header() with our own
function that looks at the Content-Type that people are sending, and turn off
output buffering if necessary. But what we've been bitten by is the inability
to completely turn off output compression once it has been turned on with

ob_end_{clean,flush} will stop the output buffering and compression, but the
header 'Content-Encoding: gzip' is already sent, at that point. Since we can't
(to my knowledge, please correct me if this is the case) remove the header, the
best we can do is replace it with the second header() parameter, which
unfortunately doesn't do the job as far as the browsers are concerned.  

Two ideas: 

-we could change zlib.c to, when output buffering+compression is on, not call
sapi_add_header (with the Content-Encoding header) until a ob_end_flush happens
or the buffer is flushed implicitly at the end of program's execution. If an
ob_end_clean were to happen, the header is not sent at all. That seems like
more correct behavior, but someone more familiar with the code will have to
speak to the feasibility of this.


-write an extension wrapping the appropriate Apache API calls so that one, from
PHP, can manipulate (read: delete) the headers in Apache's output buffer, like
you can in Perl. My guess is that this probably would already have been done if
there were not some significant obstacles.



John Donagher
Application Engineer, Intacct Corp.

Public key available off http://www.keyserver.net
Key fingerprint = 4024 DF50 56EE 19A3 258A  D628 22DE AD56 EEBE 8DDD

PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to