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

Bug #15305 deflate content encoding handled incorrectly
Submitted: 2008-12-15 14:11 UTC
From: streety Assigned: avb
Status: Closed Package: HTTP_Request2 (version 0.1.0)
PHP Version: 5.2.6 OS: irrelevant
Roadmaps: 0.2.0    
Subscription  


 [2008-12-15 14:11 UTC] streety (Jonathan Street)
Description: ------------ Whilst switching from HTTP_Request to HTTP_Request2 for the Services_WindowsLive_Contacts package I've found that the content is incorrectly decoded. Switching from gzuncompress to gzinflate solved this problem. Expected result: ---------------- Content is inflated to original content. Actual result: -------------- Warning: gzuncompress() [function.gzuncompress]: data error in /home/torren/public_html/external-libs/HTTP/Request2/Response.php on line 521

Comments

 [2008-12-15 14:16 UTC] streety (Jonathan Street)
Forgot to mention that this is an issue when content-encoding is set to deflate.
 [2008-12-28 13:37 UTC] avb (Alexey Borzov)
Can you please give an URL of the site giving this error? Need one to test it myself here, obviously.
 [2009-01-05 11:35 UTC] streety (Jonathan Street)
The actual site I had a problem with requires specific headers to be set so would be a bad choice for the purposes of testing. Most sites seem to use gzip by default but some can be forced to use deflate. For example the following code: <?php require_once("HTTP/Request2.php"); $httpObject = new HTTP_Request2(); $params = array('protocol_version' => '1.1'); $uri = 'http://www.msn.com/'; $httpObject->setConfig($params); $httpObject->setUrl($uri); $httpObject->setHeader("accept-encoding", "deflate"); $httpObject->setMethod('GET'); $response = $httpObject->send(); echo $response->getStatus(); echo ' '; echo strlen($response->getBody()); var_dump($response->getHeader()); ?> returns: 200 Warning: gzuncompress() [function.gzuncompress]: data error in C:\Users\s0678364\wamp\bin\php\php5.2.5\PEAR\HTTP\Request2\Response.php on line 522 0array(11) { ["date"]=> string(29) "Mon, 05 Jan 2009 11:32:42 GMT" ["server"]=> string(17) "Microsoft-IIS/6.0" ["p3p"]=> string(48) "CP="BUS CUR CONo FIN IVDo ONL OUR PHY SAMo TELo"" ["s"]=> string(12) "TK2PTLRENB12" ["x-powered-by"]=> string(7) "ASP.NET" ["x-aspnet-version"]=> string(9) "2.0.50727" ["pragma"]=> string(8) "no-cache" ["cache-control"]=> string(8) "no-cache" ["content-type"]=> string(24) "text/html; charset=utf-8" ["content-encoding"]=> string(7) "deflate" ["content-length"]=> string(5) "15849" } Applying the patch and using the same sample script returns: 200 50993array(11) { ["date"]=> string(29) "Mon, 05 Jan 2009 11:34:09 GMT" ["server"]=> string(17) "Microsoft-IIS/6.0" ["p3p"]=> string(48) "CP="BUS CUR CONo FIN IVDo ONL OUR PHY SAMo TELo"" ["s"]=> string(12) "TK2PTLRENB11" ["x-powered-by"]=> string(7) "ASP.NET" ["x-aspnet-version"]=> string(9) "2.0.50727" ["pragma"]=> string(8) "no-cache" ["cache-control"]=> string(8) "no-cache" ["content-type"]=> string(24) "text/html; charset=utf-8" ["content-encoding"]=> string(7) "deflate" ["content-length"]=> string(5) "15850" }
 [2009-01-06 21:35 UTC] avb (Alexey Borzov)
Fixed in CVS. Looks like RFC 2616 defined 'deflate' encoding as 'deflate' stream from RFC 1951 with 'zlib' header and trailer from RFC 1950. Some existing implementations (e.g. IIS) just send 'deflate' stream without any header. Response now checks for presence of 'zlib' header and calls gzuncompress() or gzinflate() accordingly.