diff --git a/benchmark/http/bench-parser.js b/benchmark/http/bench-parser.js index f2c120cd97f133..aacbac626f3c36 100644 --- a/benchmark/http/bench-parser.js +++ b/benchmark/http/bench-parser.js @@ -24,14 +24,14 @@ function main({ len, n }) { bench.start(); for (let i = 0; i < n; i++) { parser.execute(header, 0, header.length); - parser.initialize(REQUEST, {}); + parser.initialize(REQUEST); } bench.end(n); } function newParser(type) { const parser = new HTTPParser(); - parser.initialize(type, {}); + parser.initialize(type); parser.headers = []; diff --git a/lib/_http_client.js b/lib/_http_client.js index 00b59f357fa45d..ea4b443e89cb1b 100644 --- a/lib/_http_client.js +++ b/lib/_http_client.js @@ -127,13 +127,6 @@ function validateHost(host, name) { return host; } -class HTTPClientAsyncResource { - constructor(type, req) { - this.type = type; - this.req = req; - } -} - function ClientRequest(input, options, cb) { OutgoingMessage.call(this); @@ -824,7 +817,6 @@ function tickOnSocket(req, socket) { const lenient = req.insecureHTTPParser === undefined ? isLenient() : req.insecureHTTPParser; parser.initialize(HTTPParser.RESPONSE, - new HTTPClientAsyncResource('HTTPINCOMINGMESSAGE', req), req.maxHeaderSize || 0, lenient ? kLenientAll : kLenientNone); parser.socket = socket; diff --git a/lib/_http_common.js b/lib/_http_common.js index 96d9bdfc9fcbe5..beb71de15bfd98 100644 --- a/lib/_http_common.js +++ b/lib/_http_common.js @@ -187,10 +187,6 @@ function freeParser(parser, req, socket) { // Make sure the parser's stack has unwound before deleting the // corresponding C++ object through .close(). setImmediate(closeParserInstance, parser); - } else { - // Since the Parser destructor isn't going to run the destroy() callbacks - // it needs to be triggered manually. - parser.free(); } } if (req) { diff --git a/lib/_http_server.js b/lib/_http_server.js index e00d3cac0490e5..a2e04665493889 100644 --- a/lib/_http_server.js +++ b/lib/_http_server.js @@ -687,7 +687,6 @@ function connectionListenerInternal(server, socket) { // https://github.com/nodejs/node/pull/21313 parser.initialize( HTTPParser.REQUEST, - new HTTPServerAsyncResource('HTTPINCOMINGMESSAGE', socket), server.maxHeaderSize || 0, lenient ? kLenientAll : kLenientNone, server[kConnections], @@ -997,7 +996,7 @@ function resOnFinish(req, res, socket, state, server) { // If the user never called req.read(), and didn't pipe() or // .resume() or .on('data'), then we call req._dump() so that the // bytes will be pulled off the wire. - if (!req._consuming && !req._readableState.resumeScheduled) + if (!req._consuming && !req._readableState.resumeScheduled && !req._readableState.paused) req._dump(); res.detachSocket(socket); diff --git a/src/async_wrap.h b/src/async_wrap.h index 5b33290b4bb2d0..88ca5430cea627 100644 --- a/src/async_wrap.h +++ b/src/async_wrap.h @@ -49,8 +49,6 @@ namespace node { V(HTTP2STREAM) \ V(HTTP2PING) \ V(HTTP2SETTINGS) \ - V(HTTPINCOMINGMESSAGE) \ - V(HTTPCLIENTREQUEST) \ V(JSSTREAM) \ V(JSUDPWRAP) \ V(MESSAGEPORT) \ diff --git a/src/node_http_parser.cc b/src/node_http_parser.cc index acebdd952eb943..e32721b8e44635 100644 --- a/src/node_http_parser.cc +++ b/src/node_http_parser.cc @@ -23,7 +23,6 @@ #include "node_buffer.h" #include "util.h" -#include "async_wrap-inl.h" #include "env-inl.h" #include "llhttp.h" #include "memory_tracker-inl.h" @@ -250,17 +249,16 @@ class ConnectionsList : public BaseObject { std::set active_connections_; }; -class Parser : public AsyncWrap, public StreamListener { +class Parser : public BaseObject, public StreamListener { friend class ConnectionsList; friend struct ParserComparator; public: Parser(BindingData* binding_data, Local wrap) - : AsyncWrap(binding_data->env(), wrap), + : BaseObject(binding_data->env(), wrap), current_buffer_len_(0), current_buffer_data_(nullptr), - binding_data_(binding_data) { - } + binding_data_(binding_data) {} SET_NO_MEMORY_INFO() SET_MEMORY_INFO_NAME(Parser) @@ -289,13 +287,7 @@ class Parser : public AsyncWrap, public StreamListener { Local cb = object()->Get(env()->context(), kOnMessageBegin) .ToLocalChecked(); if (cb->IsFunction()) { - InternalCallbackScope callback_scope( - this, InternalCallbackScope::kSkipTaskQueues); - - MaybeLocal r = cb.As()->Call( - env()->context(), object(), 0, nullptr); - - if (r.IsEmpty()) callback_scope.MarkAsFailed(); + USE(cb.As()->Call(env()->context(), object(), 0, nullptr)); } return 0; @@ -442,14 +434,8 @@ class Parser : public AsyncWrap, public StreamListener { argv[A_UPGRADE] = Boolean::New(env()->isolate(), parser_.upgrade); - MaybeLocal head_response; - { - InternalCallbackScope callback_scope( - this, InternalCallbackScope::kSkipTaskQueues); - head_response = cb.As()->Call( - env()->context(), object(), arraysize(argv), argv); - if (head_response.IsEmpty()) callback_scope.MarkAsFailed(); - } + MaybeLocal head_response = cb.As()->Call( + env()->context(), object(), arraysize(argv), argv); int64_t val; @@ -478,9 +464,10 @@ class Parser : public AsyncWrap, public StreamListener { Local buffer = Buffer::Copy(env, at, length).ToLocalChecked(); - MaybeLocal r = MakeCallback(cb.As(), 1, &buffer); + v8::TryCatch try_catch(env->isolate()); + USE(cb.As()->Call(env->context(), object(), 1, &buffer)); - if (r.IsEmpty()) { + if (try_catch.HasCaught()) { got_exception_ = true; llhttp_set_error_reason(&parser_, "HPE_JS_EXCEPTION:JS Exception"); return HPE_USER; @@ -516,15 +503,11 @@ class Parser : public AsyncWrap, public StreamListener { if (!cb->IsFunction()) return 0; - MaybeLocal r; - { - InternalCallbackScope callback_scope( - this, InternalCallbackScope::kSkipTaskQueues); - r = cb.As()->Call(env()->context(), object(), 0, nullptr); - if (r.IsEmpty()) callback_scope.MarkAsFailed(); - } - if (r.IsEmpty()) { + v8::TryCatch try_catch(env()->isolate()); + USE(cb.As()->Call(env()->context(), object(), 0, nullptr)); + + if (try_catch.HasCaught()) { got_exception_ = true; return -1; } @@ -571,17 +554,6 @@ class Parser : public AsyncWrap, public StreamListener { delete parser; } - - static void Free(const FunctionCallbackInfo& args) { - Parser* parser; - ASSIGN_OR_RETURN_UNWRAP(&parser, args.This()); - - // Since the Parser destructor isn't going to run the destroy() callbacks - // it needs to be triggered manually. - parser->EmitTraceEventDestroy(); - parser->EmitDestroy(); - } - static void Remove(const FunctionCallbackInfo& args) { Parser* parser; ASSIGN_OR_RETURN_UNWRAP(&parser, args.This()); @@ -638,25 +610,24 @@ class Parser : public AsyncWrap, public StreamListener { ConnectionsList* connectionsList = nullptr; CHECK(args[0]->IsInt32()); - CHECK(args[1]->IsObject()); - if (args.Length() > 2) { - CHECK(args[2]->IsNumber()); + if (args.Length() > 1) { + CHECK(args[1]->IsNumber()); max_http_header_size = - static_cast(args[2].As()->Value()); + static_cast(args[1].As()->Value()); } if (max_http_header_size == 0) { max_http_header_size = env->options()->max_http_header_size; } - if (args.Length() > 3) { - CHECK(args[3]->IsInt32()); - lenient_flags = args[3].As()->Value(); + if (args.Length() > 2) { + CHECK(args[2]->IsInt32()); + lenient_flags = args[2].As()->Value(); } - if (args.Length() > 4 && !args[4]->IsNullOrUndefined()) { - CHECK(args[4]->IsObject()); - ASSIGN_OR_RETURN_UNWRAP(&connectionsList, args[4]); + if (args.Length() > 3 && !args[3]->IsNullOrUndefined()) { + CHECK(args[3]->IsObject()); + ASSIGN_OR_RETURN_UNWRAP(&connectionsList, args[3]); } llhttp_type_t type = @@ -668,13 +639,6 @@ class Parser : public AsyncWrap, public StreamListener { // Should always be called from the same context. CHECK_EQ(env, parser->env()); - AsyncWrap::ProviderType provider = - (type == HTTP_REQUEST ? - AsyncWrap::PROVIDER_HTTPINCOMINGMESSAGE - : AsyncWrap::PROVIDER_HTTPCLIENTREQUEST); - - parser->set_provider_type(provider); - parser->AsyncReset(args[1].As()); parser->Init(type, max_http_header_size, lenient_flags); if (connectionsList != nullptr) { @@ -820,7 +784,13 @@ class Parser : public AsyncWrap, public StreamListener { current_buffer_len_ = nread; current_buffer_data_ = buf.base; - MakeCallback(cb.As(), 1, &ret); + v8::TryCatch try_catch(env()->isolate()); + USE(cb.As()->Call(env()->context(), object(), 1, &ret)); + + if (try_catch.HasCaught()) { + got_exception_ = true; + return; + } current_buffer_len_ = 0; current_buffer_data_ = nullptr; @@ -935,12 +905,12 @@ class Parser : public AsyncWrap, public StreamListener { url_.ToString(env()) }; - MaybeLocal r = MakeCallback(cb.As(), - arraysize(argv), - argv); + v8::TryCatch try_catch(env()->isolate()); + USE(cb.As()->Call(env()->context(), object(), arraysize(argv), argv)); - if (r.IsEmpty()) + if (try_catch.HasCaught()) { got_exception_ = true; + } url_.Reset(); have_flushed_ = true; @@ -1299,9 +1269,7 @@ void CreatePerIsolateProperties(IsolateData* isolate_data, t->Set(FIXED_ONE_BYTE_STRING(isolate, "kLenientAll"), Integer::NewFromUnsigned(isolate, kLenientAll)); - t->Inherit(AsyncWrap::GetConstructorTemplate(isolate_data)); SetProtoMethod(isolate, t, "close", Parser::Close); - SetProtoMethod(isolate, t, "free", Parser::Free); SetProtoMethod(isolate, t, "remove", Parser::Remove); SetProtoMethod(isolate, t, "execute", Parser::Execute); SetProtoMethod(isolate, t, "finish", Parser::Finish); @@ -1372,7 +1340,6 @@ void CreatePerContextProperties(Local target, void RegisterExternalReferences(ExternalReferenceRegistry* registry) { registry->Register(Parser::New); registry->Register(Parser::Close); - registry->Register(Parser::Free); registry->Register(Parser::Remove); registry->Register(Parser::Execute); registry->Register(Parser::Finish); diff --git a/test/async-hooks/test-graph.http.js b/test/async-hooks/test-graph.http.js index 859000b14aa8e0..c8b920aa2ff19a 100644 --- a/test/async-hooks/test-graph.http.js +++ b/test/async-hooks/test-graph.http.js @@ -36,13 +36,7 @@ process.on('exit', () => { { type: 'TCPCONNECTWRAP', id: 'tcpconnect:1', triggerAsyncId: 'tcp:1' }, - { type: 'HTTPCLIENTREQUEST', - id: 'httpclientrequest:1', - triggerAsyncId: 'tcpserver:1' }, { type: 'TCPWRAP', id: 'tcp:2', triggerAsyncId: 'tcpserver:1' }, - { type: 'HTTPINCOMINGMESSAGE', - id: 'httpincomingmessage:1', - triggerAsyncId: 'tcp:2' }, { type: 'Timeout', id: 'timeout:1', triggerAsyncId: null }, diff --git a/test/async-hooks/test-httpparser-reuse.js b/test/async-hooks/test-httpparser-reuse.js deleted file mode 100644 index f7ce2cd876220e..00000000000000 --- a/test/async-hooks/test-httpparser-reuse.js +++ /dev/null @@ -1,75 +0,0 @@ -'use strict'; - -const common = require('../common'); -const assert = require('assert'); -const { createHook } = require('async_hooks'); -const http = require('http'); - -// Verify that resource emitted for an HTTPParser is not reused. -// Verify that correct create/destroy events are emitted. - -const reused = Symbol('reused'); - -const reusedParser = []; -const incomingMessageParser = []; -const clientRequestParser = []; -const dupDestroys = []; -const destroyed = []; - -createHook({ - init(asyncId, type, triggerAsyncId, resource) { - switch (type) { - case 'HTTPINCOMINGMESSAGE': - incomingMessageParser.push(asyncId); - break; - case 'HTTPCLIENTREQUEST': - clientRequestParser.push(asyncId); - break; - } - - if (resource[reused]) { - reusedParser.push( - `resource reused: ${asyncId}, ${triggerAsyncId}, ${type}`, - ); - } - resource[reused] = true; - }, - destroy(asyncId) { - if (destroyed.includes(asyncId)) { - dupDestroys.push(asyncId); - } else { - destroyed.push(asyncId); - } - }, -}).enable(); - -const server = http.createServer((req, res) => { - res.end(); -}); - -server.listen(0, common.mustCall(() => { - const PORT = server.address().port; - const url = `http://127.0.0.1:${PORT}`; - http.get(url, common.mustCall(() => { - server.close(common.mustCall(() => { - server.listen(PORT, common.mustCall(() => { - http.get(url, common.mustCall(() => { - server.close(common.mustCall(() => { - setTimeout(common.mustCall(verify), 200); - })); - })); - })); - })); - })); -})); - -function verify() { - assert.strictEqual(reusedParser.length, 0); - - assert.strictEqual(incomingMessageParser.length, 2); - assert.strictEqual(clientRequestParser.length, 2); - - assert.strictEqual(dupDestroys.length, 0); - incomingMessageParser.forEach((id) => assert.ok(destroyed.includes(id))); - clientRequestParser.forEach((id) => assert.ok(destroyed.includes(id))); -} diff --git a/test/async-hooks/test-httpparser.request.js b/test/async-hooks/test-httpparser.request.js deleted file mode 100644 index 40c01bc8177d6e..00000000000000 --- a/test/async-hooks/test-httpparser.request.js +++ /dev/null @@ -1,53 +0,0 @@ -'use strict'; - -const common = require('../common'); -const assert = require('assert'); -const tick = require('../common/tick'); -const initHooks = require('./init-hooks'); -const { checkInvocations } = require('./hook-checks'); - -const hooks = initHooks(); -hooks.enable(); - -const { HTTPParser } = require('_http_common'); - -const REQUEST = HTTPParser.REQUEST; - -const kOnHeadersComplete = HTTPParser.kOnHeadersComplete | 0; - -const request = Buffer.from( - 'GET /hello HTTP/1.1\r\n\r\n', -); - -const parser = new HTTPParser(); -parser.initialize(REQUEST, {}); -const as = hooks.activitiesOfTypes('HTTPINCOMINGMESSAGE'); -const httpparser = as[0]; - -assert.strictEqual(as.length, 1); -assert.strictEqual(typeof httpparser.uid, 'number'); -assert.strictEqual(typeof httpparser.triggerAsyncId, 'number'); -checkInvocations(httpparser, { init: 1 }, 'when created new Httphttpparser'); - -parser[kOnHeadersComplete] = common.mustCall(onheadersComplete); -parser.execute(request, 0, request.length); - -function onheadersComplete() { - checkInvocations(httpparser, { init: 1, before: 1 }, - 'when onheadersComplete called'); - tick(1, common.mustCall(tick1)); -} - -function tick1() { - parser.close(); - tick(1); -} - -process.on('exit', onexit); - -function onexit() { - hooks.disable(); - hooks.sanityCheck('HTTPINCOMINGMESSAGE'); - checkInvocations(httpparser, { init: 1, before: 1, after: 1, destroy: 1 }, - 'when process exits'); -} diff --git a/test/async-hooks/test-httpparser.response.js b/test/async-hooks/test-httpparser.response.js deleted file mode 100644 index 64f0893c5a9aa8..00000000000000 --- a/test/async-hooks/test-httpparser.response.js +++ /dev/null @@ -1,64 +0,0 @@ -'use strict'; - -const common = require('../common'); -const assert = require('assert'); -const tick = require('../common/tick'); -const initHooks = require('./init-hooks'); -const { checkInvocations } = require('./hook-checks'); - -const hooks = initHooks(); - -hooks.enable(); - -const { HTTPParser } = require('_http_common'); - -const RESPONSE = HTTPParser.RESPONSE; -const kOnHeadersComplete = HTTPParser.kOnHeadersComplete | 0; -const kOnBody = HTTPParser.kOnBody | 0; - -const request = Buffer.from( - 'HTTP/1.1 200 OK\r\n' + - 'Content-Type: text/plain\r\n' + - 'Content-Length: 4\r\n' + - '\r\n' + - 'pong', -); - -const parser = new HTTPParser(); -parser.initialize(RESPONSE, {}); -const as = hooks.activitiesOfTypes('HTTPCLIENTREQUEST'); -const httpparser = as[0]; - -assert.strictEqual(as.length, 1); -assert.strictEqual(typeof httpparser.uid, 'number'); -assert.strictEqual(typeof httpparser.triggerAsyncId, 'number'); -checkInvocations(httpparser, { init: 1 }, 'when created new Httphttpparser'); - -parser[kOnHeadersComplete] = common.mustCall(onheadersComplete); -parser[kOnBody] = common.mustCall(onbody); -parser.execute(request, 0, request.length); - -function onheadersComplete() { - checkInvocations(httpparser, { init: 1, before: 1 }, - 'when onheadersComplete called'); -} - -function onbody() { - checkInvocations(httpparser, { init: 1, before: 2, after: 1 }, - 'when onbody called'); - tick(1, common.mustCall(tick1)); -} - -function tick1() { - parser.close(); - tick(1); -} - -process.on('exit', onexit); - -function onexit() { - hooks.disable(); - hooks.sanityCheck('HTTPCLIENTREQUEST'); - checkInvocations(httpparser, { init: 1, before: 2, after: 2, destroy: 1 }, - 'when process exits'); -} diff --git a/test/parallel/test-async-hooks-http-parser-destroy.js b/test/parallel/test-async-hooks-http-parser-destroy.js deleted file mode 100644 index 6cbc2043b09583..00000000000000 --- a/test/parallel/test-async-hooks-http-parser-destroy.js +++ /dev/null @@ -1,92 +0,0 @@ -'use strict'; -const common = require('../common'); -const assert = require('assert'); -const async_hooks = require('async_hooks'); -const http = require('http'); - -// Regression test for https://github.com/nodejs/node/issues/19859. -// Checks that matching destroys are emitted when creating new/reusing old http -// parser instances. - -const N = 50; -const KEEP_ALIVE = 100; - -const createdIdsIncomingMessage = []; -const createdIdsClientRequest = []; -const destroyedIdsIncomingMessage = []; -const destroyedIdsClientRequest = []; - -async_hooks.createHook({ - init: (asyncId, type) => { - if (type === 'HTTPINCOMINGMESSAGE') { - createdIdsIncomingMessage.push(asyncId); - } - if (type === 'HTTPCLIENTREQUEST') { - createdIdsClientRequest.push(asyncId); - } - }, - destroy: (asyncId) => { - if (createdIdsIncomingMessage.includes(asyncId)) { - destroyedIdsIncomingMessage.push(asyncId); - } - if (createdIdsClientRequest.includes(asyncId)) { - destroyedIdsClientRequest.push(asyncId); - } - - if (destroyedIdsClientRequest.length === N && keepAliveAgent) { - keepAliveAgent.destroy(); - keepAliveAgent = undefined; - } - - if (destroyedIdsIncomingMessage.length === N && server.listening) { - server.close(); - } - } -}).enable(); - -const server = http.createServer((req, res) => { - req.on('close', common.mustCall(() => { - req.on('readable', common.mustNotCall()); - })); - res.end('Hello'); -}); - -let keepAliveAgent = new http.Agent({ - keepAlive: true, - keepAliveMsecs: KEEP_ALIVE, -}); - -server.listen(0, () => { - for (let i = 0; i < N; ++i) { - (function makeRequest() { - http.get({ - port: server.address().port, - agent: keepAliveAgent - }, (res) => { - res.resume(); - }); - })(); - } -}); - -function checkOnExit() { - assert.strictEqual(createdIdsIncomingMessage.length, N); - assert.strictEqual(createdIdsClientRequest.length, N); - assert.strictEqual(destroyedIdsIncomingMessage.length, N); - assert.strictEqual(destroyedIdsClientRequest.length, N); - - assert.deepStrictEqual(destroyedIdsIncomingMessage.sort(), - createdIdsIncomingMessage.sort()); - assert.deepStrictEqual(destroyedIdsClientRequest.sort(), - createdIdsClientRequest.sort()); -} - -process.on('SIGTERM', () => { - // Catching SIGTERM and calling `process.exit(1)` so that the `exit` event - // is triggered and the assertions are checked. This can be useful for - // troubleshooting this test if it times out. - process.exit(1); -}); - -// Ordinary exit. -process.on('exit', checkOnExit); diff --git a/test/parallel/test-http-parser-bad-ref.js b/test/parallel/test-http-parser-bad-ref.js index e34054eca67063..4d5f779bcc59cc 100644 --- a/test/parallel/test-http-parser-bad-ref.js +++ b/test/parallel/test-http-parser-bad-ref.js @@ -25,7 +25,7 @@ function demoBug(part1, part2) { flushPool(); const parser = new HTTPParser(); - parser.initialize(HTTPParser.REQUEST, {}); + parser.initialize(HTTPParser.REQUEST); parser.headers = []; parser.url = ''; diff --git a/test/parallel/test-http-parser-lazy-loaded.js b/test/parallel/test-http-parser-lazy-loaded.js index 44bb59f052e6ce..6e1d613c43d4b9 100644 --- a/test/parallel/test-http-parser-lazy-loaded.js +++ b/test/parallel/test-http-parser-lazy-loaded.js @@ -24,7 +24,7 @@ const { parsers } = require('_http_common'); // Test _http_common was not loaded before monkey patching const parser = parsers.alloc(); -parser.initialize(DummyParser.REQUEST, {}); +parser.initialize(DummyParser.REQUEST); assert.strictEqual(parser instanceof DummyParser, true); assert.strictEqual(parser.test_type, DummyParser.REQUEST); diff --git a/test/parallel/test-http-parser-timeout-reset.js b/test/parallel/test-http-parser-timeout-reset.js index 9a7eab42a6beaf..0f0b227e03273b 100644 --- a/test/parallel/test-http-parser-timeout-reset.js +++ b/test/parallel/test-http-parser-timeout-reset.js @@ -26,7 +26,6 @@ const server = net.createServer((socket) => { const parser = new HTTPParser(HTTPParser.RESPONSE, false); parser.initialize( HTTPParser.RESPONSE, - {}, 0, 0, ); diff --git a/test/parallel/test-http-parser.js b/test/parallel/test-http-parser.js index ad591319089c1a..decd667f868a4f 100644 --- a/test/parallel/test-http-parser.js +++ b/test/parallel/test-http-parser.js @@ -39,7 +39,7 @@ const kOnMessageComplete = HTTPParser.kOnMessageComplete | 0; function newParser(type) { const parser = new HTTPParser(); - parser.initialize(type, {}); + parser.initialize(type); parser.headers = []; parser.url = ''; @@ -96,7 +96,7 @@ function expectBody(expected) { throw new Error('hello world'); }; - parser.initialize(REQUEST, {}); + parser.initialize(REQUEST); assert.throws( () => { parser.execute(request, 0, request.length); }, @@ -518,14 +518,6 @@ function expectBody(expected) { '0\r\n' ); - const req2 = Buffer.from( - 'POST /that HTTP/1.0\r\n' + - 'Content-Type: text/plain\r\n' + - 'Content-Length: 4\r\n' + - '\r\n' + - 'pong' - ); - const onHeadersComplete1 = (versionMajor, versionMinor, headers, method, url) => { assert.strictEqual(method, methods.indexOf('PUT')); @@ -537,27 +529,10 @@ function expectBody(expected) { ['Content-Type', 'text/plain', 'Transfer-Encoding', 'chunked']); }; - const onHeadersComplete2 = (versionMajor, versionMinor, headers, - method, url) => { - assert.strictEqual(method, methods.indexOf('POST')); - assert.strictEqual(url, '/that'); - assert.strictEqual(versionMajor, 1); - assert.strictEqual(versionMinor, 0); - assert.deepStrictEqual( - headers, - ['Content-Type', 'text/plain', 'Content-Length', '4'] - ); - }; - const parser = newParser(REQUEST); parser[kOnHeadersComplete] = onHeadersComplete1; parser[kOnBody] = expectBody('ping'); parser.execute(req1, 0, req1.length); - - parser.initialize(REQUEST, req2); - parser[kOnBody] = expectBody('pong'); - parser[kOnHeadersComplete] = onHeadersComplete2; - parser.execute(req2, 0, req2.length); } // Test parser 'this' safety diff --git a/test/sequential/test-async-wrap-getasyncid.js b/test/sequential/test-async-wrap-getasyncid.js index cd5957de11e157..73b651a82f07b6 100644 --- a/test/sequential/test-async-wrap-getasyncid.js +++ b/test/sequential/test-async-wrap-getasyncid.js @@ -56,8 +56,6 @@ const { getSystemErrorName } = require('util'); delete providers.SIGNREQUEST; delete providers.VERIFYREQUEST; delete providers.HASHREQUEST; - delete providers.HTTPCLIENTREQUEST; - delete providers.HTTPINCOMINGMESSAGE; delete providers.ELDHISTOGRAM; delete providers.SIGINTWATCHDOG; delete providers.WORKERHEAPSNAPSHOT; @@ -169,16 +167,6 @@ if (common.hasCrypto) { // eslint-disable-line node-core/crypto-check testInitialized(new StatWatcher(), 'StatWatcher'); } - -{ - const { HTTPParser } = require('_http_common'); - const parser = new HTTPParser(); - testUninitialized(parser, 'HTTPParser'); - parser.initialize(HTTPParser.REQUEST, {}); - testInitialized(parser, 'HTTPParser'); -} - - { const Gzip = require('zlib').Gzip; testInitialized(new Gzip()._handle, 'Zlib'); diff --git a/test/sequential/test-http-regr-gh-2928.js b/test/sequential/test-http-regr-gh-2928.js index f6a9e1603288a4..6cd82e0be6c865 100644 --- a/test/sequential/test-http-regr-gh-2928.js +++ b/test/sequential/test-http-regr-gh-2928.js @@ -25,7 +25,7 @@ function execAndClose() { process.stdout.write('.'); const parser = parsers.pop(); - parser.initialize(HTTPParser.RESPONSE, {}); + parser.initialize(HTTPParser.RESPONSE); const socket = net.connect(common.PORT, common.localhostIPv4); socket.on('error', (e) => { diff --git a/typings/internalBinding/async_wrap.d.ts b/typings/internalBinding/async_wrap.d.ts index 0bcff6e30c6b42..34dfd16644767c 100644 --- a/typings/internalBinding/async_wrap.d.ts +++ b/typings/internalBinding/async_wrap.d.ts @@ -28,46 +28,44 @@ declare namespace InternalAsyncWrapBinding { HTTP2STREAM: 14; HTTP2PING: 15; HTTP2SETTINGS: 16; - HTTPINCOMINGMESSAGE: 17; - HTTPCLIENTREQUEST: 18; - JSSTREAM: 19; - JSUDPWRAP: 20; - MESSAGEPORT: 21; - PIPECONNECTWRAP: 22; - PIPESERVERWRAP: 23; - PIPEWRAP: 24; - PROCESSWRAP: 25; - PROMISE: 26; - QUERYWRAP: 27; - SHUTDOWNWRAP: 28; - SIGNALWRAP: 29; - STATWATCHER: 30; - STREAMPIPE: 31; - TCPCONNECTWRAP: 32; - TCPSERVERWRAP: 33; - TCPWRAP: 34; - TTYWRAP: 35; - UDPSENDWRAP: 36; - UDPWRAP: 37; - SIGINTWATCHDOG: 38; - WORKER: 39; - WORKERHEAPSNAPSHOT: 40; - WRITEWRAP: 41; - ZLIB: 42; - CHECKPRIMEREQUEST: 43; - PBKDF2REQUEST: 44; - KEYPAIRGENREQUEST: 45; - KEYGENREQUEST: 46; - KEYEXPORTREQUEST: 47; - CIPHERREQUEST: 48; - DERIVEBITSREQUEST: 49; - HASHREQUEST: 50; - RANDOMBYTESREQUEST: 51; - RANDOMPRIMEREQUEST: 52; - SCRYPTREQUEST: 53; - SIGNREQUEST: 54; - TLSWRAP: 55; - VERIFYREQUEST: 56; + JSSTREAM: 17; + JSUDPWRAP: 18; + MESSAGEPORT: 19; + PIPECONNECTWRAP: 20; + PIPESERVERWRAP: 21; + PIPEWRAP: 22; + PROCESSWRAP: 23; + PROMISE: 24; + QUERYWRAP: 25; + SHUTDOWNWRAP: 26; + SIGNALWRAP: 27; + STATWATCHER: 28; + STREAMPIPE: 29; + TCPCONNECTWRAP: 30; + TCPSERVERWRAP: 31; + TCPWRAP: 32; + TTYWRAP: 33; + UDPSENDWRAP: 34; + UDPWRAP: 35; + SIGINTWATCHDOG: 36; + WORKER: 37; + WORKERHEAPSNAPSHOT: 38; + WRITEWRAP: 39; + ZLIB: 40; + CHECKPRIMEREQUEST: 41; + PBKDF2REQUEST: 42; + KEYPAIRGENREQUEST: 43; + KEYGENREQUEST: 44; + KEYEXPORTREQUEST: 45; + CIPHERREQUEST: 46; + DERIVEBITSREQUEST: 47; + HASHREQUEST: 48; + RANDOMBYTESREQUEST: 49; + RANDOMPRIMEREQUEST: 50; + SCRYPTREQUEST: 51; + SIGNREQUEST: 52; + TLSWRAP: 53; + VERIFYREQUEST: 54; } }