forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http: reset headers timeout on headers complete
headers timeout should not occur *after* headers have been received. Fixes: nodejs#34576 PR-URL: nodejs#34578 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Pranshu Srivastava <rexagod@gmail.com>
- Loading branch information
Showing
2 changed files
with
47 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
|
||
const net = require('net'); | ||
const { HTTPParser } = process.binding('http_parser'); | ||
|
||
const server = net.createServer((socket) => { | ||
socket.write('HTTP/1.1 200 OK\r\n'); | ||
socket.write('Transfer-Encoding: chunked\r\n\r\n'); | ||
setTimeout(() => { | ||
socket.write('1\r\n'); | ||
socket.write('\n\r\n'); | ||
setTimeout(() => { | ||
socket.write('1\r\n'); | ||
socket.write('\n\r\n'); | ||
setImmediate(() => { | ||
socket.destroy(); | ||
server.close(); | ||
}); | ||
}, 500); | ||
}, 500); | ||
}).listen(0, () => { | ||
const socket = net.connect(server.address().port); | ||
const parser = new HTTPParser(HTTPParser.RESPONSE, false); | ||
parser.initialize( | ||
HTTPParser.RESPONSE, | ||
{}, | ||
0, | ||
false, | ||
1e3 | ||
); | ||
|
||
parser[HTTPParser.kOnTimeout] = common.mustNotCall(); | ||
|
||
parser[HTTPParser.kOnHeaders] = common.mustNotCall(); | ||
|
||
parser[HTTPParser.kOnExecute] = common.mustCall(3); | ||
|
||
parser[HTTPParser.kOnHeadersComplete] = common.mustCall(); | ||
|
||
parser[HTTPParser.kOnBody] = common.mustCall(2); | ||
|
||
parser[HTTPParser.kOnMessageComplete] = common.mustNotCall(); | ||
|
||
parser.consume(socket._handle); | ||
}); |