-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http: disable headersTimeout check when set to zero
PR-URL: #33307 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
- Loading branch information
1 parent
5c0232a
commit ebd9090
Showing
3 changed files
with
57 additions
and
2 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
49 changes: 49 additions & 0 deletions
49
test/parallel/test-http-server-disabled-headers-timeout.js
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,49 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const { createServer } = require('http'); | ||
const { connect } = require('net'); | ||
|
||
// This test verifies that it is possible to disable | ||
// headersTimeout by setting it to zero. | ||
|
||
const server = createServer(common.mustCall((req, res) => { | ||
res.writeHead(200); | ||
res.end('OK'); | ||
})); | ||
|
||
server.headersTimeout = 0; | ||
|
||
server.once('timeout', common.mustNotCall((socket) => { | ||
socket.destroy(); | ||
})); | ||
|
||
server.listen(0, common.mustCall(() => { | ||
const client = connect(server.address().port); | ||
let response = ''; | ||
|
||
client.resume(); | ||
client.write('GET / HTTP/1.1\r\nConnection: close\r\n'); | ||
|
||
// All the timeouts below must be greater than a second, otherwise | ||
// headersTimeout won't be triggered anyway as the current date is cached | ||
// for a second in HTTP internals. | ||
setTimeout(() => { | ||
client.write('X-Crash: Ab: 456\r\n'); | ||
}, common.platformTimeout(1100)).unref(); | ||
|
||
setTimeout(() => { | ||
client.write('\r\n'); | ||
}, common.platformTimeout(1200)).unref(); | ||
|
||
client.on('data', (chunk) => { | ||
response += chunk.toString('utf-8'); | ||
}); | ||
|
||
client.on('end', common.mustCall(() => { | ||
assert.strictEqual(response.split('\r\n').shift(), 'HTTP/1.1 200 OK'); | ||
client.end(); | ||
server.close(); | ||
})); | ||
})); |