-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http: improved timeout defaults handling
Co-authored-by: Luigi Pinca <[email protected]> PR-URL: #45778 Fixes: #43355 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Santiago Gimeno <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]>
- Loading branch information
Showing
3 changed files
with
59 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
'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' } | ||
); | ||
} |