Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 2.6.0

Request #11246 Problem with deflate encoding
Submitted: 2007-06-07 11:01 UTC
From: fredericpoeydomenge Assigned: avb
Status: Closed Package: HTTP_Request2
PHP Version: 5.2.2 OS: Debian Etch 4.0
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 24 + 27 = ?

 
 [2007-06-07 11:01 UTC] fredericpoeydomenge (Frederic Poeydomenge)
Description: ------------ The problem comes when requesting the page http://tf1.fr with the "deflate" encoding. Depending on the User-Agent, the page is not decoded at all (first line addHeader('User-Agent'...) below) , or it is well decoded (second line). To see this bug in effect, uncomment the second addHeader('User-Agent'...) in the script below. I suppose that the server is not serving exactly the same content for these two user-agents, and that in one case, HTTP_Request does not know how to decode the result ? I've been able to make it work by : 1- modifying the "gzipped" boolean (including "deflate" algorithm) $gzipped = isset($this->_headers['content-encoding']) && ('gzip' == $this->_headers['content-encoding'] || 'deflate' == $this->_headers['content-encoding']); 2 - replacing _decodeGzip($data) call simply with gzinflate($data); That's why I think that HTTP_Request is not decoding the page as it should do, but I am not able to detect where the problem lie... Test script: --------------- <?php require 'HTTP/Request.php'; $request = new HTTP_Request( 'http://tf1.fr', array( 'method' => HTTP_REQUEST_METHOD_GET, 'http' => HTTP_REQUEST_HTTP_VER_1_1 ) ); $request->addHeader('User-Agent', 'Mozilla/5.0 (X11; U; Linux i686; fr; rv:1.8.1.3) Gecko/20070310 Iceweasel/2.0.0.3 (Debian-2.0.0.3-1)'); //$request->addHeader('User-Agent', 'Mozilla/5.0 (X11; U; Linux i686; fr; rv:1.8.1.3) G*cko/20070310 Iceweasel/2.0.0.3 (Debian-2.0.0.3-1)'); $request->addHeader('Accept-Encoding', 'gzip,deflate'); $err = $request->sendRequest(); if (PEAR::isError($err)) { die($err->getMessage()); } else { var_dump($request->getResponseBody()); } ?> Expected result: ---------------- decoded page Actual result: -------------- encoded page

Comments

 [2007-06-21 10:48 UTC] avb (Alexey Borzov)
HTTP_Request never claimed support for 'deflate' Content-Encoding and never automatically added 'Accept-Encoding: deflate' to the request header. Therefore, strictly speaking, this is the error on your part to add this header and expect HTTP_Request to properly handle the encoded data. On the other hand, this can be recategorized as feature request, but the implementation should conform to the proper RFCs mentioned in section 3.5 of RFC 2616: "deflate The "zlib" format defined in RFC 1950 in combination with the "deflate" compression mechanism described in RFC 1951."
 [2008-10-17 21:15 UTC] avb (Alexey Borzov)
Moving feature requests to HTTP_Request2.
 [2008-11-17 13:34 UTC] avb (Alexey Borzov)
Implemented in HTTP_Request2 0.1.0