Error GZIP header, second magic byte doesn't match

Joined
Jan 23, 2006
Messages
4
Reaction score
0
Hi,
I use the http://www.icsharpcode.net/OpenSource/SharpZipLib/Default.aspx library witch I think is great. Sadly I have one problem with it.
I get the error:
Error GZIP header, second magic byte doesn't match

I'm using the following code for the unzipping:
if (hwr != null)
{
if (hwr.ContentEncoding == "gzip" || hwr.ContentEncoding == "deflate")
{

totalbuff = Decompress(totalbuff, hwr.ContentEncoding);
//GZipOutputStream compressedStream = new GZipOutputStream();
}
}


private byte[] Decompress(byte[] b, string CompressionType)
{
try
{

Stream s;

switch (CompressionType.ToLower())
{

case "deflate":
s = new InflaterInputStream(new MemoryStream(b), new Inflater(true));
break;
case "gzip":
s = new GZipInputStream(new MemoryStream(b));
break;
default:
return b;
}

MemoryStream ms = new MemoryStream();
const int intChunkSize = 2048;

int intSizeRead;
byte[] unzipBytes = new byte[intChunkSize + 1];
while (true)
{
intSizeRead = s.Read(unzipBytes, 0, intChunkSize);
if (intSizeRead > 0)
{
ms.Write(unzipBytes, 0, intSizeRead);
}
else
{
break; // TODO: might not be correct. Was : Exit While
}
}
s.Close();

return ms.ToArray();
}
catch (GZipException gze)
{
Add2TextBox(gze.Message);
MemoryStream ms = new MemoryStream();
return ms.ToArray();
}
}

I'm trying to download a yahoo search page:
http://search.yahoo.com/search;_ylt...=yfp-t-501&ei=UTF-8&fp_ip=SE&rd=r1&meta=vc=se[^]

Using fiddler to help me.
In the raw data I get:
31 33 39 35 20 20 20 0D 0A 1F 8B 08 00 00 00 00 00 00 03 EC 5C FD 73 DB

It starts with the number:
1395

RAW header looks like this:
HTTP/1.1 200 OK
Date: Fri, 02 May 2008 10:42:10 GMT
P3P: policyref="http://p3p.yahoo.com/w3c/p3p.xml", CP="CAO DSP COR CUR ADM DEV TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE GOV"
Set-Cookie: sSN=mvE0CkoGkndDqoaREUWO9RBJUeMiL0ga8AIACkUw; expires=Fri, 02-May-2008 11:12:10 GMT; path=/; domain=.search.yahoo.com
Cache-Control: private
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html; charset=ISO-8859-1
Content-Encoding: gzip

1395

I would really appreciate your help on this.
Sincerely
Andla
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top