kopia lustrzana https://github.com/viljoviitanen/pako
Fixed ungzip: force window size when not set, because autodetect impossible
rodzic
21c21df425
commit
07173737fc
|
@ -100,6 +100,16 @@ var Inflate = function(options) {
|
|||
opt.windowBits += 32;
|
||||
}
|
||||
|
||||
// Gzip header has no info about windows size, we can do autodetect only
|
||||
// for deflate. So, if window size not set, force it to max when gzip possible
|
||||
if ((opt.windowBits > 15) && (opt.windowBits < 48)) {
|
||||
// bit 3 (16) -> gzipped data
|
||||
// bit 4 (32) -> autodetect gzip/deflate
|
||||
if ((opt.windowBits & 15) === 0) {
|
||||
opt.windowBits |= 15;
|
||||
}
|
||||
}
|
||||
|
||||
this.err = 0; // error code, if happens (0 = Z_OK)
|
||||
this.msg = ''; // error message
|
||||
this.ended = false; // used to avoid multiple onEnd() calls
|
||||
|
|
|
@ -28,12 +28,12 @@ describe('Inflate ungzip', function () {
|
|||
// TODO: Investigate, why ungzip does not autodetect window size and
|
||||
// require to set windowBits directly
|
||||
|
||||
it.skip('with autodetect', function(done) {
|
||||
it('with autodetect', function(done) {
|
||||
testInflate(samples, {}, { gzip: true }, done);
|
||||
});
|
||||
|
||||
it('with method set directly', function(done) {
|
||||
testInflate(samples, { windowBits: 15 + 16 }, { gzip: true }, done);
|
||||
testInflate(samples, { windowBits: 16 }, { gzip: true }, done);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue