mirror of
https://github.com/nodejs/node.git
synced 2025-05-06 20:08:02 +00:00

PR-URL: https://github.com/nodejs/node/pull/16540 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Khaidi Chu <i@2333.moe> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
58 lines
1.4 KiB
JavaScript
58 lines
1.4 KiB
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
|
|
const assert = require('assert');
|
|
const zlib = require('zlib');
|
|
|
|
// For raw deflate encoding, requests for 256-byte windows are rejected as
|
|
// invalid by zlib (http://zlib.net/manual.html#Advanced).
|
|
// This check was introduced in version 1.2.9 and prior to that there was
|
|
// no such rejection which is the reason for the version check below
|
|
// (http://zlib.net/ChangeLog.txt).
|
|
if (!/^1\.2\.[0-8]$/.test(process.versions.zlib)) {
|
|
common.expectsError(
|
|
() => zlib.createDeflateRaw({ windowBits: 8 }),
|
|
{
|
|
code: 'ERR_ZLIB_INITIALIZATION_FAILED',
|
|
type: Error,
|
|
message: 'Initialization failed'
|
|
});
|
|
}
|
|
|
|
// Regression tests for bugs in the validation logic.
|
|
|
|
common.expectsError(
|
|
() => zlib.createGzip({ chunkSize: 0 }),
|
|
{
|
|
code: 'ERR_INVALID_OPT_VALUE',
|
|
type: RangeError
|
|
}
|
|
);
|
|
|
|
common.expectsError(
|
|
() => zlib.createGzip({ windowBits: 0 }),
|
|
{
|
|
code: 'ERR_INVALID_OPT_VALUE',
|
|
type: RangeError
|
|
}
|
|
);
|
|
|
|
common.expectsError(
|
|
() => zlib.createGzip({ memLevel: 0 }),
|
|
{
|
|
code: 'ERR_INVALID_OPT_VALUE',
|
|
type: RangeError
|
|
}
|
|
);
|
|
|
|
{
|
|
const stream = zlib.createGzip({ level: NaN });
|
|
assert.strictEqual(stream._level, zlib.constants.Z_DEFAULT_COMPRESSION);
|
|
}
|
|
|
|
{
|
|
const stream = zlib.createGzip({ strategy: NaN });
|
|
assert.strictEqual(stream._strategy, zlib.constants.Z_DEFAULT_STRATEGY);
|
|
}
|