From: Mike Simons [mailto:[EMAIL PROTECTED]

> On Tue, Mar 25, 2003 at 02:21:21PM -0000, Paul Marquess wrote:

...

>
>   The auto-detection is kinda nice, but what I think is much more
> valuable is to allow a stream based (block by block) compress and
> decompress mode for the data stream if possible.

Already done.

> It should also be
> possible for a user to *not* allow auto detection if they want to...

Indeed. The auto-detection will either be a parameter to the decompression
constructor, or more likely I'll wrap it in a HTTP-specific sub-class of
Compress::Zlib.

> ===
> ($d, $status) = inflateInit([OPT]);
> ($output, $status) = $d->inflate($buffer);
> ($status) = $d->inflateDone();
> ===
>
>   The Init can safe the CRC, length, and other useful header portions
> into the $d object.  The values could be referenced by the user (once
> enough of the header has arrived).

Yep, for Gzip, the object allows access to all the information in the gzip
header (and when writing a Gzip file/buffer, you have full control over all
the gzip headers). Unfortunately, neither the crc or the length live in the
header block. Both are in the trailer block.

>
> Options like:
> ===
>   'CheckCRC' => 1    # calculate a running crc,
>                      # and match with header at Done call
>
>   'DataType' => ("rfc1950", "rfc1951", "gzip")
>                      # array of which data compression types to support
>                      # whichever rfc is more common could be aliased to
>                      # "deflate" ;)
> ===
>
>   The inflate would feed blocks of data into the decompression engine.
> $output could be "", for the first blocks of $buffer, (if small blocks
> are fed in and the header has not finished).

At the moment, when decompressing gzip format, the first block *must*
include the complete gzip header.

> inflate shouldn't buffer data.

For part of that you are at the mercy of zlib.

>   Done would indicate there is no more data, and the length and crc
> could be checked if requested at Init time... some useful error messages
> could be returned.
>
> - What do you think of this?

It's not that far from what I've actually implemented.

>   The deflate code could be much like what's above, but people would
> HAVE to supply a crc32 and length value to Init do use gzip type
> compression... and when Done is invoked if the CRC doesn't match or
> if the length isn't right you return an error code... ;)

I don't see the need for the user to have to supply the CRC/length. This is
worked out behind the scenes as the gzip file/buffer is being created.

Paul

Reply via email to