http: simplify drain()

Simplify and slightly optimize draining outgoing http streams. Avoid
extra event listener and inline with rest of the drain logic.

PR-URL: https://github.com/nodejs/node/pull/29081
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This commit is contained in:
Robert Nagy
2019-08-11 11:09:40 +02:00
committed by Rich Trott
parent a0cc62f345
commit bdf07f4317
5 changed files with 26 additions and 27 deletions

View File

@@ -31,7 +31,6 @@ const { methods, HTTPParser } =
internalBinding('http_parser') : internalBinding('http_parser_llhttp');
const FreeList = require('internal/freelist');
const { ondrain } = require('internal/http');
const incoming = require('_http_incoming');
const {
IncomingMessage,
@@ -201,12 +200,6 @@ function freeParser(parser, req, socket) {
}
}
function httpSocketSetup(socket) {
socket.removeListener('drain', ondrain);
socket.on('drain', ondrain);
}
const tokenRegExp = /^[\^_`a-zA-Z\-0-9!#$%&'*+.|~]+$/;
/**
* Verifies that the given val is a valid HTTP token
@@ -253,7 +246,6 @@ module.exports = {
CRLF: '\r\n',
debug,
freeParser,
httpSocketSetup,
methods,
parsers,
kIncomingMessage,