emarkp
8/22/2006 5:01:00 PM
In article <20060822054708.GA8197@eviladmins.lan>,
Aaron Patterson <aaron_patterson@speakeasy.net> wrote:
>I'm trying to unzip a string I have in memory, but unfortunately I keep
>getting a 'incorrect header check (Zlib::DataError)' when I try to unzip
>the string.
>
>The weird thing is that I can write the string out to a file, and unzip
>it using gzip or even Zlib::GzipReader.
>
>For example, using the same file, this works:
>
> require 'zlib'
>
> File.open(ARGV[0], 'r') { |f|
> gz = Zlib::GzipReader.new(f)
> puts gz.read
> }
>
>But this doesn't (it fails with 'incorrect header check'):
>
> require 'zlib'
>
> File.open(ARGV[0], 'r') { |f|
> puts Zlib::Inflate.inflate(f.read)
> }
>
>Anyone have any hints? Thanks.
A Gzip file has a header which includes the original filename. A
zlib-compressed string doesn't have the same header.
--
Mark Ping
emarkp@soda.CSUA.Berkeley.EDU