Closed Bug 129021 Opened 22 years ago Closed 22 years ago

header("Content-Encoding: gzip") doesn't decode right

Categories

(Core :: Networking: HTTP, defect)

defect
Not set
critical

Tracking

()

CLOSED INVALID

People

(Reporter: g.richner, Assigned: darin.moz)

Details

From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:0.9.8) Gecko/20020204
BuildID:    2002020406

I have written a php page with
"header("Content-Encoding: gzip");"
and it works fine with opera5&6, netscape 4.7x, InetEx but is not decoded for
Mozilla and Netscape 6.2.1
It looks like someone forgot to put in a decode method for gzip or deflate... 
even if the browser keeps telling:
_SERVER["HTTP_ACCEPT_ENCODING"]gzip, deflate, compress;q=0.9 

there are two posibilities to resolve this problem:
1. remove the HTTP_ACCEPT_ENCODING line ... OR
2. put in the right decoding procedure/method 

CU
Gregor Richner

Reproducible: Always
Steps to Reproduce:
1.read description above
2.
3.

Actual Results:  read description above

Expected Results:  read description above

read description above
1. please provide a testcase
2. please don't give us ultimatums until someone has had time to analyze the 
problem (and even then, ultimatums are hardly welcome).
Assignee: asa → darin
Component: Browser-General → Networking: HTTP
QA Contact: doronr → tever
testcase PHP4 source:

<?php
if(strstr($HTTP_SERVER_VARS['HTTP_ACCEPT_ENCODING'],'gzip'))
{
// Start output buffering, and register compress_output() (see 
// below)

ob_start("compress_output");
// Tell the browser the content is compressed with gzip
header("Content-Encoding: gzip");
print ("<center><h3>This is a gzip-compressed text...</h3></center>");
}
else
if(strstr($HTTP_SERVER_VARS['HTTP_ACCEPT_ENCODING'],'x-gzip'))
{
// Start output buffering, and register compress_output() (see 
// below)
ob_start("compress_output");
// Tell the browser the content is compressed with x-gzip
header("Content-Encoding: x-gzip");
print ("<center><h3>This is a x-gzip-compressed text...</h3></center>");
}
else
{
print ("<center><h3>This is a uncompressed text... Text</h3></center>");
}
?>
Summary: header("Content-Encoding: gzip") does'nt decode right → header("Content-Encoding: gzip") doesn't decode right
Are you using gzip?  Or deflate?  Or both?  We have issues with deflate, but
gzip should be working (there are plenty of pages out there where it does).  Is
there a live test page we can see this on?  (I have no PHP here).
reporter: are you trying to view the document, save it to a file, or feed it to
a helper app?  thx!
the script (Additional Comment #2) checks if the browser can gzip or x-gzip or nothing
and then it 
prints the appropriate text in the browser window (no other appication involved).
So... does php3 support encoding like that?  I have a php3 setup I could test
on.  Failing that, is it possible to put a small testcase online so that I could
get a look at what we send to the server and what we get back?
sorry "ob_start" is not defined in php3 and this is needed to prevent php from sending headers 
before your header is send...
I am trying to put the above test case on a reachable server but I 
cannot promise that!

OR 
compile php and apache for yourself on Linux/UNIX it looks 
like

./configure --with-apache=../path/to/apachesrc --with-zlib=yes --with-xml --enable-trans-
sid --enable-inline-optimization --enable-magic-quotes --enable-sockets --enable-sysvsem --enable-
sysvshm --enable-shmop --enable-calendar --enable-memory-limit --enable-force-cgi-redirect --enable-
discard-path --enable-sigchild --with-openssl --with-imap-ssl

make

make 
install

./configure --activate-module=src/modules/php4/libphp4.a --
prefix=/usr/local/apache  --sbindir=/usr/sbin --enable-module=so

make 

make 
install

/usr/sbin/apachectl start

copy the Additional Comment #2 script to 
/usr/local/apache/htdocs/

you can also make the following script to see a testpage of the 
php installation:
<?php
phpinfo();
?>

download PHPsrc on 
http://www.php.net/
download APACHEsrc on http://www.apache.org/

CU
Gregor 
Richner
oops

I forgot to tell you to edit the /usr/local/apache/conf/httpd.conf

find the line 
beginning with
AddType application

then insert the following

AddType 
application/x-httpd-php .php .php4
AddType application/x-httpd-php-source .phps

CU 

Gregor Richner

PS: "make install" is one line
sent via email:

> Hi guys,
> 
> the bug mentioned at http://bugzilla.mozilla.org/show_bug.cgi?id=129021 is 
> not a bug.
> 
> I played up the PHP code on my domain, it does not compress any output, but 
> it sets a "Content-Encoding: gzip" header nevertheless. That's the reason, 
> why mozilla is confused. It is waiting for gzip-output but does only get 
> normal output.
> 
> You can test it with lynx on my domain 
> 
>     http://d42.de/falsezip.php
> 
> A call of "lynx -mime_header -source http://d42.de/falsezip.php" shows what 
> is actually happening:
> 
>   HTTP/1.1 200 OK
>   Date: Sun, 14 Apr 2002 00:13:50 GMT
>   Server: Apache/1.3.22 (Unix)
>   Content-Encoding: gzip
>                     ^^^^ <-- pretends to be gzip-encoding
>   X-Powered-By: PHP/4.1.1
>   Connection: close
>   Content-Type: text/html
> 
>   <center><h3>This is a gzip-compressed text...</h3></center>
>   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>   ^-- Just non-encoded output, no gzip at all
> 
> 
> So mozilla gets confused by gzip output which is no gzip output at all. I 
> also wrote a PHP script which does actually gzip the output, visible at 
> http://d42.de/truezip.php 
> 
> A call of "lynx -mime_header -source http://d42.de/truezip.php" shows what is 
> actually happening:
> 
>   HTTP/1.1 200 OK
>   Date: Sun, 14 Apr 2002 00:17:46 GMT
>   Server: Apache/1.3.22 (Unix)
>   Content-Encoding: gzip
>                     ^^^^ <- Says it will deliver compressed output
>   Vary: Accept-Encoding
>   X-Powered-By: PHP/4.1.1
>   Content-Length: 79
>   Connection: close
>   Content-Type: text/html
> 
>   ²INÍ+I-²³É0¶
>               ÉÈ,V¢D…ôªÌÝäüÜ‚¢ÔââÔ…’ÔŠ=== *¨.ÿÿΙå
>   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>   ^-- I can't read this, so it must be gzipped output.
> 
> Sorry, I fear I did everything wrong with mailing this comment, instead of 
> entering it into bugzilla, but I am tired, in a hurry and I did not really 
> understand how to use this bugzilla thing. I will look at it again when I am 
> less tired ;-). Gregor, can you enter this into Bugzilla for me?
> 
> Greetings
> Benjamin Schwenk

marking INVALID
Status: UNCONFIRMED → RESOLVED
Closed: 22 years ago
Resolution: --- → INVALID
I tried this out and have to agree with Benjamin Schwenk...

you have to put two lines in php.ini to make php able to compress data for ALL
php contents: 

output_buffering=ON
output_handler=ob_gzhandler


the handler is in php>=4.04

thanx
Gregor Richner
Status: RESOLVED → CLOSED
You need to log in before you can comment on or make changes to this bug.