Forum Moderators: coopster

Message Too Old, No Replies

zlib not sending proper MIME types?

Latest build of PHP 4 on FreeBSD with zlib sending our garbage characters..

         

Thanasus

7:10 am on Sep 7, 2004 (gmt 0)

10+ Year Member



I have looked through my php.ini and httpd.conf files numerous times and cannot determine what is happening here.

When I try to set zlib output compression either in my php.ini or a virtual hosts entry in my httpd.conf file, all I get is garbage characters. I am guess that apache is not properly sending out a MIME type identifying the compressed file, so my browser is rendering compressed data.

I have the following in my httpd.conf:

AddEncoding x-compress .Z
AddEncoding x-gzip .gz .tgz
AddType application/x-tar .tgz

mincklerstraat

8:35 am on Sep 7, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



One thing you can do is check out the server headers to see what info is being sent, including mime type (appears as 'Content-type' in the headers). The free 'web developer' toolbar available as a firefox extension has been invaluable to me, and one of my favorite thingies on it is the headers viewer - great if your ap depends a lot on the headers which are sent, or if you're trying to make your ap more 'caching aware,' etc. If you're not up for this, you can use a header viewer at [delorie.com...]

I'm not such a specialist on apache and mime types, but one possible way you might be able to hack yourself out of this before you really figure things out (like if you need to be deployed now) is just put header('Content-Encoding: gzip'); somewhere in your script before there's anything output to the browser. Check php.net also on header() to see the various options regarding overwriting previous headers if for some reason these headers are being sent.

Another thing to try: the function ob_gzhandler();

Thanasus

10:43 am on Sep 7, 2004 (gmt 0)

10+ Year Member



Looking at the headers, I see the problem is that when I set zlib.output_compression to "on" in the php.ini, then it compresses the page but does NOT send the proper MIME type, it just says its HTML/text

However, if I set an output_handler to ob_gzhandler, then it compresses and sends the proper MIME type.

Strange....