mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 21:19:50 +01:00
77f4985e32
Co-authored-by: Luigi Pinca <luigipinca@gmail.com> PR-URL: https://github.com/nodejs/node/pull/45778 Fixes: https://github.com/nodejs/node/issues/43355 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
51 lines
1.3 KiB
JavaScript
51 lines
1.3 KiB
JavaScript
'use strict';
|
|
|
|
require('../common');
|
|
const assert = require('assert');
|
|
const { createServer } = require('http');
|
|
|
|
// This test validates that the HTTP server timeouts are properly validated and set.
|
|
|
|
{
|
|
const server = createServer();
|
|
assert.strictEqual(server.headersTimeout, 60000);
|
|
assert.strictEqual(server.requestTimeout, 300000);
|
|
}
|
|
|
|
{
|
|
const server = createServer({ headersTimeout: 10000, requestTimeout: 20000 });
|
|
assert.strictEqual(server.headersTimeout, 10000);
|
|
assert.strictEqual(server.requestTimeout, 20000);
|
|
}
|
|
|
|
{
|
|
const server = createServer({ headersTimeout: 10000, requestTimeout: 10000 });
|
|
assert.strictEqual(server.headersTimeout, 10000);
|
|
assert.strictEqual(server.requestTimeout, 10000);
|
|
}
|
|
|
|
{
|
|
const server = createServer({ headersTimeout: 10000 });
|
|
assert.strictEqual(server.headersTimeout, 10000);
|
|
assert.strictEqual(server.requestTimeout, 300000);
|
|
}
|
|
|
|
{
|
|
const server = createServer({ requestTimeout: 20000 });
|
|
assert.strictEqual(server.headersTimeout, 20000);
|
|
assert.strictEqual(server.requestTimeout, 20000);
|
|
}
|
|
|
|
{
|
|
const server = createServer({ requestTimeout: 100000 });
|
|
assert.strictEqual(server.headersTimeout, 60000);
|
|
assert.strictEqual(server.requestTimeout, 100000);
|
|
}
|
|
|
|
{
|
|
assert.throws(
|
|
() => createServer({ headersTimeout: 10000, requestTimeout: 1000 }),
|
|
{ code: 'ERR_OUT_OF_RANGE' }
|
|
);
|
|
}
|