Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
24b927a
build: allow clang 10+ in configure.py
krytarowski Sep 13, 2019
145dcc2
build: move doc versions JSON file out of out/doc
richardlau Apr 8, 2020
5436569
test: flaky test-stdout-close-catch on freebsd
sam-github Apr 14, 2020
9915774
build: log detected compilers in --verbose mode
richardlau Apr 8, 2020
89a306b
deps: fix V8 compiler error with clang++-11
sam-github Apr 27, 2020
3acc89f
deps: V8: backport cd21f71f9cb5
targos Jun 13, 2020
aaf2f82
inspector: more conservative minimum stack size
bnoordhuis May 24, 2019
ef9413b
deps: upgrade openssl sources to 1.1.1f
hassaanp Mar 31, 2020
94702c1
deps: upgrade openssl sources to 1.1.1g
hassaanp Apr 21, 2020
745b329
deps: update archs files for OpenSSL-1.1.1g
hassaanp Apr 21, 2020
74b00cc
tls: allow empty subject even with altNames defined
jasonmacgowan Sep 17, 2018
193d1d0
doc: document fs.watchFile() bigint option
cjihrig Mar 6, 2020
3dbd8cd
Revert "test: mark empty udp tests flaky on OS X"
lpinca Mar 25, 2020
961598b
n-api: add `napi_detach_arraybuffer`
legendecas Apr 25, 2020
b744ffd
n-api: implement napi_is_detached_arraybuffer
lundibundi Nov 23, 2019
5dab101
doc,n-api: mark napi_detach_arraybuffer as experimental
legendecas Nov 28, 2019
069b6e1
http: disable headersTimeout check when set to zero
ShogunPanda Apr 29, 2020
84fca3c
deps: upgrade npm to 6.14.5
ruyadorno May 4, 2020
97b5952
deps: upgrade npm to 6.14.6
claudiahdz Jul 7, 2020
7a109fe
test: remove timers-blocking-callback
Fishrock123 Apr 15, 2020
00f04e3
doc: fix quotes in tls.md
sparsh-99 May 29, 2020
c5215d0
2020-07-21, Version 10.22.0 'Dubnium' (LTS)
richardlau Jul 2, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
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
ShogunPanda authored and richardlau committed Jul 2, 2020
commit 069b6e14a423f4f51aaaaf758d076e95526c5d98
4 changes: 3 additions & 1 deletion doc/api/http.md
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@ added: v0.1.90

Stops the server from accepting new connections. See [`net.Server.close()`][].

### server.listen()
### `server.listen()`

Starts the HTTP server listening for connections.
This method is identical to [`server.listen()`][] from [`net.Server`][].
Expand Down Expand Up @@ -984,6 +984,8 @@ event is emitted on the server object, and (by default) the socket is destroyed.
See [server.timeout][] for more information on how timeout behaviour can be
customised.

A value of `0` will disable the HTTP headers timeout check.

### server.setTimeout([msecs][, callback])
<!-- YAML
added: v0.9.12
Expand Down
8 changes: 6 additions & 2 deletions lib/_http_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -501,8 +501,12 @@ function onParserExecute(server, socket, parser, state, ret) {

// If we have not parsed the headers, destroy the socket
// after server.headersTimeout to protect from DoS attacks.
// start === 0 means that we have parsed headers.
if (start !== 0 && nowDate() - start > server.headersTimeout) {
// start === 0 means that we have parsed headers, while
// server.headersTimeout === 0 means user disabled this check.
if (
start !== 0 && server.headersTimeout &&
nowDate() - start > server.headersTimeout
) {
const serverTimeout = server.emit('timeout', socket);

if (!serverTimeout)
Expand Down
49 changes: 49 additions & 0 deletions test/parallel/test-http-server-disabled-headers-timeout.js
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();
}));
}));