[ 
https://issues.apache.org/jira/browse/COMPRESS-263?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14032609#comment-14032609
 ] 

Matthias Stevens commented on COMPRESS-263:
-------------------------------------------

I've done some more research regarding auto-detection of DEFLATE streams with a 
zlib header.
It turns out the "ZLIB Compressed Data Format Specification" 
(http://tools.ietf.org/html/rfc1950) does unfortunately not define a "magic 
number"-like identifier. However, the first 4 bits in the header (a field 
called named "CM", for "Compression Method") should effectively always have the 
value 8, which indicates the compression method is DEFLATE. The Zlib format 
specification mentions that "Other compressed data formats [besides DEFLATE] 
are not specified in this version of the zlib specification".
So based on these specs alone (I haven't verified it yet in practise), it 
appears safe to assume that all valid DEFLATEd files with a zlib header will 
start with CM = 8.

> Add DEFLATE support
> -------------------
>
>                 Key: COMPRESS-263
>                 URL: https://issues.apache.org/jira/browse/COMPRESS-263
>             Project: Commons Compress
>          Issue Type: New Feature
>          Components: Compressors
>            Reporter: Matthias Stevens
>              Labels: features
>             Fix For: 1.9
>
>         Attachments: COMPRESS-263_DeflateSupport.patch, 
> COMPRESS-263_DeflateSupport_v1.1.patch, bla.tar.deflate, bla.tar.deflatez
>
>
> GZIP is not a compression algorithm "as such". The de facto (and currently 
> the only supported) compression algorithm it uses is DEFLATE.
> GZIP adds a header of minimum 10 bytes and a footer of 8 bytes to a 
> "deflated" data stream. Find out more here: 
> http://en.wikipedia.org/wiki/Gzip#File_format
> I have no problem with the current GZIP support, but it would be nice if 
> CommonsCompress would also have compression and decompression support for 
> "raw" DEFLATE streams and DEFLATE streams with the zlib header.
> Similarly to the GZIP support in CommonsCompress these functionality can be 
> implemented very easily using the standard java.util.zip package, as done in 
> the provided patch.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to