Skip to content

Commit

Permalink
Emit a RFC 1952 compatible XFL flag again
Browse files Browse the repository at this point in the history
RFC 1952 specifies the following values
for the XFL flag:

* 2: maximum compression, slowest
* 4: fastest algorithm config

Commit 7e0390b has
changed our behaviour from conforming to that
to setting the XFL flag to 9 when compression
is best, and 0 when it is the fastest one.

We revert that change in order to have consistent
output with pre 1.0.0 versions of flate2 and also
to be consistent with RFC 1952 and the ecosystem
around it, e.g. unix tooling that assumes the
RFC specified layout for the XFL flag.

Fixes rust-lang#137.
  • Loading branch information
est31 committed Nov 30, 2017
1 parent 044ac12 commit a336dae
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/gz/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,13 @@ impl GzBuilder {
header[5] = (mtime >> 8) as u8;
header[6] = (mtime >> 16) as u8;
header[7] = (mtime >> 24) as u8;
header[8] = lvl.0 as u8;
header[8] = if lvl.0 >= Compression::best().0 {
2
} else if lvl.0 <= Compression::fast().0 {
4
} else {
0
};

// Typically this byte indicates what OS the gz stream was created on,
// but in an effort to have cross-platform reproducible streams just
Expand Down

0 comments on commit a336dae

Please sign in to comment.