mirror of https://github.com/lukechilds/node.git
Browse Source
Up to now, `Z_FINISH` was always the flushing flag that was used for the last chunk of input data. This patch makes this choice configurable so that advanced users can perform e.g. decompression of partial data using `Z_SYNC_FLUSH`, if that suits their needs. Add tests to make sure that an error is thrown upon encountering invalid `flush` or `finishFlush` flags. Fixes: https://github.com/nodejs/node/issues/5761 PR-URL: https://github.com/nodejs/node/pull/6069 Reviewed-By: James M Snell <jasnell@gmail.com>v6.x
Anna Henningsen
9 years ago
committed by
James M Snell
4 changed files with 91 additions and 12 deletions
@ -0,0 +1,28 @@ |
|||
'use strict'; |
|||
require('../common'); |
|||
const assert = require('assert'); |
|||
const zlib = require('zlib'); |
|||
|
|||
assert.doesNotThrow(() => { |
|||
zlib.createGzip({ flush: zlib.Z_SYNC_FLUSH }); |
|||
}); |
|||
|
|||
assert.throws(() => { |
|||
zlib.createGzip({ flush: 'foobar' }); |
|||
}, /Invalid flush flag: foobar/); |
|||
|
|||
assert.throws(() => { |
|||
zlib.createGzip({ flush: 10000 }); |
|||
}, /Invalid flush flag: 10000/); |
|||
|
|||
assert.doesNotThrow(() => { |
|||
zlib.createGzip({ finishFlush: zlib.Z_SYNC_FLUSH }); |
|||
}); |
|||
|
|||
assert.throws(() => { |
|||
zlib.createGzip({ finishFlush: 'foobar' }); |
|||
}, /Invalid flush flag: foobar/); |
|||
|
|||
assert.throws(() => { |
|||
zlib.createGzip({ finishFlush: 10000 }); |
|||
}, /Invalid flush flag: 10000/); |
Loading…
Reference in new issue