diff --git a/src/node_http_parser.cc b/src/node_http_parser.cc index c7a3df8d067af4..555a25e0d3f94b 100644 --- a/src/node_http_parser.cc +++ b/src/node_http_parser.cc @@ -297,6 +297,8 @@ class Parser : public AsyncWrap, public StreamListener { A_MAX }; + header_parsing_start_time_ = 0; + Local argv[A_MAX]; Local obj = object(); Local cb = obj->Get(env()->context(), diff --git a/test/parallel/test-http-parser-timeout-reset.js b/test/parallel/test-http-parser-timeout-reset.js new file mode 100644 index 00000000000000..7d5bafa435e96a --- /dev/null +++ b/test/parallel/test-http-parser-timeout-reset.js @@ -0,0 +1,46 @@ +'use strict'; +const common = require('../common'); + +const net = require('net'); +const { HTTPParser } = process.binding('http_parser'); // eslint-disable-line + +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); +});