Board index » delphi » Re: How to handle gz files fetched with IdHTTP?
Stig Johansen
![]() Delphi Developer |
Re: How to handle gz files fetched with IdHTTP?2008-06-05 01:17:45 PM delphi110 Bo Berglund writes: QuoteOn Wed, 04 Jun 2008 23:18:23 +0200, Stig Johansen <XXXX@XXXXX.COM> deflate, and not gzip. On the other hand we had the other browsers, which supported gzip, but not deflate. I needed to support both, so thats where my jurney started. I discovered that deflate was 'just' the compressed data without the headers. And gzip was just the compressed/deflated data with header and checksum. So you can look at gzip roughly as: gzip := header + compressed_data + trailer. So when you do this (from your other post): Res?= IdHTTP1.Get('tv.swedb.se/xmltv/channels.xml.gz'); Your Res contains the above construction. What i am talking about is basically to exctract the compressed_data part from the file/string/stream. QuoteTZDecompressionStream.Create(TFileStream.Create(gzfile, sure where exactly the compressed_part starts in the file/string/stream. Quote
..... function ZReceiveFromBrowser(const s: string) : string; var outBuf: Pointer; outBytes: Integer; begin ZDecompress2(pointer(s), length(s), outBuf, outBytes, 0); SetLength(result, outBytes); Move(pointer(outBuf)^, pointer(result)^, outBytes); FreeMem(outBuf); end; ..... Quote>My things are from about 2002, but i think i had a hard time back then, And it decompresses fine with my programs as mentioned, so the data is correct. This is still on Linux which uses native zlib library. -- Best regards Stig Johansen |