1 Attachment(s)
[RESOLVED] Decompress GZip
Hi, I have the following response from a server. The data is GZip compressed, but I can't find a way to decompress it.
I tried this code from pscode.com, but it doesn't work (returns -1). Does it have anything to do with "charset=UTF-8" ?
http://www.planet-source-code.com/vb...64920&lngWId=1
Please note that this is not a response I got by communicating with the server myself, so I can't change "Accept-Encoding" in the header, in order to get the data in a different format.
Code:
HTTP/1.1 200 OK
Date: Sat, 01 May 2010 15:46:27 GMT
Server: Apache/2.2.14 (EL)
X-Powered-By: PHP/5.2.11
Set-Cookie: PHPSESSID=47400e3a200b9703a339fbe7c5aeda99; expires=Sat, 08-May-2010 15:46:27 GMT; path=/; domain=.host.com
Set-Cookie: PHPSESSID=47400e3a200b9703a339fbe7c5aeda99; expires=Sat, 08-May-2010 15:46:27 GMT; path=/; domain=.host.com
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 206
Connection: close
Content-Type: text/html; charset=UTF-8
‹ =ŽÁNÃ0DÿeÏQ娦Æ9S$Ä"îk{ÒDMëjTBUþ· ö8ûÞÎÞh 'u7*(eÌgêÈ:«k¥‚wʰ1¾pñ‰‘Ø{j*,×1âòçhÕ*Õêm[—A9»3‡ ‰ºY¬
Ê2Í÷®eXªe¬Q©Öë8á3ñ¸výGï™|zÇw
“cÛ'kµÛ8zÀý#ûúäí…ºç†ÆKÅsíÂæ 9_Q–ã&æ*ëáGãRø
Re: [RESOLVED] Decompress GZip
Merri I'm using your code... After I get the HTML contents (including headers) from winsock, I split the headers and the page body into an array:
Code:
BuffSplit = Split(Buffer, vbNewLine & vbNewLine, 2)
Then I call this:
Code:
Debug.Print "BeforeLen: " & Len(BuffSplit(1))
BuffSplit(1) = GZip(BuffSplit(1))
Debug.Print "AfterLen: " & Len(BuffSplit(1))
Here's what I get:
Quote:
BeforeLen: 8888
AfterLen: 0
I directly copied & pasted the GZip property/function. Please help!
Re: [RESOLVED] Decompress GZip
It expects binary data. You're apparently providing a regular VB6 string that holds binary data as characters (= most often 1 byte becomes one character ie. 2 bytes, but varies depending on locale).
BuffSplit(1) = GZip(StrConv(BuffSplit(1), vbFromUnicode))
Re: [RESOLVED] Decompress GZip
Works like a freaking charm. Merri you are so good at what you do!