php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #22967 "gzuncompress data error" while trying to uncompress TRUE gzip data
Submitted: 2003-03-30 14:57 UTC Modified: 2005-06-29 12:41 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: atz at atz dot msk dot ru Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 4CVS-2003-03-30 (stable) OS: FreeBSD 5.0-RELEASE
Private report: No CVE-ID: None
View Add Comment Developer Edit
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:
48 + 32 = ?
Subscribe to this entry?

 
 [2003-03-30 14:57 UTC] atz at atz dot msk dot ru
I'am trying to fetch data with fsockopen and etc.
from URL
http://suncity.combats.ru/inf.pl?login=atz
OR
http://capitalcity.combats.ru/inf.pl?login=atz

And as result in variable named $Data i have a compressed
gzip data from that url with "Content-encoding: gzip".

But! When i try to 
gzuncompress($Data) 
the php returns
Warning: gzuncompress(): data error 

gzinflate($Data)
Warning: gzinflate(): data error 

I'm try to do following:

$fp = fopen("gzipped","w");
fwrite($fp, $Data, strlen($Data));
fclose($fp);

$buffer = "";
$gzfp = gzopen("gzipped","r");
while (!gzeof($gzfp)) {
 $buffer .= gzread($gzfp, 1024);
}
gzclose($gzfp);

And as result i have normal UNCOMPRESSED data 
in varaiable named $buffer.

Why gzuncompress do not uncompress $Data while
gzopen do this success?

Is this a bug?

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-03-31 06:28 UTC] wez@php.net
the gzuncompress() function expects to decompress the header-less data generated by gzcompress().

The workaround is to write to a temp file and read it in, or you could just cut-off the gzip header and try gzuncompress. (the header is usually 10 bytes in length, so gzuncompress(substr($Data,10)) might work).

It looks like you need the opposite of gzencode(), which can will correctly deal with this.
 [2005-06-29 12:41 UTC] nlopess@php.net
Duplicate of #22123.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 15:01:29 2024 UTC