Bug #12884 Updated: Content-Encoding: PHP sends incorrect Content-Length when gzip is used on a re
| From: | sniper@php.net | Date: | Wed, 22 Aug 2001 05:25:40 +0000 |
| Subject: | Bug #12884 Updated: Content-Encoding: PHP sends incorrect Content-Length when gzip is used on a re | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-64009@lists.php.net to get a copy of this message | ||
ID: 12884
Updated by: sniper
Reported By: yngve@opera.com
Old Status: Open
Status: Feedback
Bug Type: HTTP related
Operating System:
PHP Version: 4.0.6
New Comment:
this should be fixed in CVS. Could you please try
the latest snapshot to verify:
http://snaps.php.net/
--Jani
Previous Comments:
------------------------------------------------------------------------
[2001-08-21 14:43:56] yngve@opera.com
I am a developer at Opera Software, in charge of the HTTP protocol support in the Opera Browser.
We recently received a report of a problem on http://www.amdforums.com .
When I investigating this report I found that the problem was caused by an incorrect Content-Length
header in combination with a Content-Encoding: gzip header.
The length indicated by the Content-Length is actually the length of the original, uncompressed
body, but it should have been the length of the compressed body (References: RFC 2616 section 4.4,
7.2 and 14.13).
The mismatch between the indicated Content-Length and the actual amount of received data causes
Opera to do repeated load attempts (This is a fallback primarily used to handle problems with
pipelining and persistent connections).
This mismatch also destroys the pipelining and persistent connection capabilities in HTTP 1.1. I
actually observed one example where the HTTP header of the next (pipelined) request was received
and added to the content of the gzipped file.
Investigating the PHP sourcecode I found that the code to add the Content-Length header was
disabled.
I am still investigating workarounds that will handle this problem, but unless it is removed on the
server side it will affect all Opera versions after v4.0, as well as any other HTTP useragent that
uses HTTP pipelining and therefore have to trust the Content-Length headers
To fix this problem you will have to replace the Content-Length header with a proper header, or
remove it. An alternative (for HTTP 1.1 clients) is to use the chunked transfer encoding.
This is an example session:
GET / HTTP/1.1
User-Agent Mozilla/3.0 (Windows 2000; U) Opera 5.50 [en]
Host www.amdforums.com
Accept text/html, image/png, image/jpeg, image/gif, image/x-xbitmap, */*
Accept-Language en
Accept-Charset iso-8859-1,*,utf-8
Accept-Encoding deflate, gzip, x-gzip, identity, *;q=0
Connection Keep-Alive, TE
TE deflate, gzip, chunked, identity, trailers
(Cookie header removed)
with the following response from the server
HTTP/1.1 200 OK
Date Mon, 13 Aug 2001 175609 GMT
Server Apache/1.3.19 (Unix) (Red-Hat/Linux) PHP/4.0.6 mod_perl/1.24_01
X-Powered-By PHP/4.0.6
Content-Length 60928
Content-Encoding gzip
Vary Accept-Encoding
Keep-Alive timeout=15, max=100
Connection Keep-Alive
Content-Type text/html
followed by an entity body of 9562 bytes of gzipped data.
The gzipped data expands to 60928 bytes of data, as specified in the content length header.
------------------------------------------------------------------------
Edit this bug report at http://bugs.php.net/?id=12884&edit=1