http,https: give names to anonymous or misnamed functions
Affected functions: - http.OutgoingMessage.prototype.cork - http.OutgoingMessage.prototype.uncork - http.Server.prototype.close - http.Server.prototype.closeAllConnections - http.Server.prototype.closeIdleConnections - http.Server.prototype[Symbol.asyncDispose] - http.Server.prototype[nodejs.rejection] - http.validateHeaderName - http.validateHeaderValue - https.Server.prototype.closeAllConnections - https.Server.prototype.closeIdleConnections - https.Server.prototype.close PR-URL: https://github.com/nodejs/node/pull/58180 Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: Ethan Arrowood <ethan@arrowood.dev> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
f56590e161
commit
cfd2021c35
@ -70,6 +70,7 @@ const {
|
|||||||
hideStackFrames,
|
hideStackFrames,
|
||||||
} = require('internal/errors');
|
} = require('internal/errors');
|
||||||
const { validateString } = require('internal/validators');
|
const { validateString } = require('internal/validators');
|
||||||
|
const { assignFunctionName } = require('internal/util');
|
||||||
const { isUint8Array } = require('internal/util/types');
|
const { isUint8Array } = require('internal/util/types');
|
||||||
|
|
||||||
let debug = require('internal/util/debuglog').debuglog('http', (fn) => {
|
let debug = require('internal/util/debuglog').debuglog('http', (fn) => {
|
||||||
@ -254,14 +255,14 @@ OutgoingMessage.prototype._renderHeaders = function _renderHeaders() {
|
|||||||
return headers;
|
return headers;
|
||||||
};
|
};
|
||||||
|
|
||||||
OutgoingMessage.prototype.cork = function() {
|
OutgoingMessage.prototype.cork = function cork() {
|
||||||
this[kCorked]++;
|
this[kCorked]++;
|
||||||
if (this[kSocket]) {
|
if (this[kSocket]) {
|
||||||
this[kSocket].cork();
|
this[kSocket].cork();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
OutgoingMessage.prototype.uncork = function() {
|
OutgoingMessage.prototype.uncork = function uncork() {
|
||||||
this[kCorked]--;
|
this[kCorked]--;
|
||||||
if (this[kSocket]) {
|
if (this[kSocket]) {
|
||||||
this[kSocket].uncork();
|
this[kSocket].uncork();
|
||||||
@ -606,13 +607,13 @@ function matchHeader(self, state, field, value) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const validateHeaderName = hideStackFrames((name, label) => {
|
const validateHeaderName = assignFunctionName('validateHeaderName', hideStackFrames((name, label) => {
|
||||||
if (typeof name !== 'string' || !name || !checkIsHttpToken(name)) {
|
if (typeof name !== 'string' || !name || !checkIsHttpToken(name)) {
|
||||||
throw new ERR_INVALID_HTTP_TOKEN.HideStackFramesError(label || 'Header name', name);
|
throw new ERR_INVALID_HTTP_TOKEN.HideStackFramesError(label || 'Header name', name);
|
||||||
}
|
}
|
||||||
});
|
}));
|
||||||
|
|
||||||
const validateHeaderValue = hideStackFrames((name, value) => {
|
const validateHeaderValue = assignFunctionName('validateHeaderValue', hideStackFrames((name, value) => {
|
||||||
if (value === undefined) {
|
if (value === undefined) {
|
||||||
throw new ERR_HTTP_INVALID_HEADER_VALUE.HideStackFramesError(value, name);
|
throw new ERR_HTTP_INVALID_HEADER_VALUE.HideStackFramesError(value, name);
|
||||||
}
|
}
|
||||||
@ -620,7 +621,7 @@ const validateHeaderValue = hideStackFrames((name, value) => {
|
|||||||
debug('Header "%s" contains invalid characters', name);
|
debug('Header "%s" contains invalid characters', name);
|
||||||
throw new ERR_INVALID_CHAR.HideStackFramesError('header content', name);
|
throw new ERR_INVALID_CHAR.HideStackFramesError('header content', name);
|
||||||
}
|
}
|
||||||
});
|
}));
|
||||||
|
|
||||||
function parseUniqueHeadersOption(headers) {
|
function parseUniqueHeadersOption(headers) {
|
||||||
if (!ArrayIsArray(headers)) {
|
if (!ArrayIsArray(headers)) {
|
||||||
|
@ -80,6 +80,7 @@ const {
|
|||||||
},
|
},
|
||||||
} = require('internal/errors');
|
} = require('internal/errors');
|
||||||
const {
|
const {
|
||||||
|
assignFunctionName,
|
||||||
kEmptyObject,
|
kEmptyObject,
|
||||||
promisify,
|
promisify,
|
||||||
} = require('internal/util');
|
} = require('internal/util');
|
||||||
@ -573,17 +574,17 @@ function Server(options, requestListener) {
|
|||||||
ObjectSetPrototypeOf(Server.prototype, net.Server.prototype);
|
ObjectSetPrototypeOf(Server.prototype, net.Server.prototype);
|
||||||
ObjectSetPrototypeOf(Server, net.Server);
|
ObjectSetPrototypeOf(Server, net.Server);
|
||||||
|
|
||||||
Server.prototype.close = function() {
|
Server.prototype.close = function close() {
|
||||||
httpServerPreClose(this);
|
httpServerPreClose(this);
|
||||||
ReflectApply(net.Server.prototype.close, this, arguments);
|
ReflectApply(net.Server.prototype.close, this, arguments);
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
Server.prototype[SymbolAsyncDispose] = async function() {
|
Server.prototype[SymbolAsyncDispose] = assignFunctionName(SymbolAsyncDispose, async function() {
|
||||||
return promisify(this.close).call(this);
|
return promisify(this.close).call(this);
|
||||||
};
|
});
|
||||||
|
|
||||||
Server.prototype.closeAllConnections = function() {
|
Server.prototype.closeAllConnections = function closeAllConnections() {
|
||||||
if (!this[kConnections]) {
|
if (!this[kConnections]) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -595,7 +596,7 @@ Server.prototype.closeAllConnections = function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Server.prototype.closeIdleConnections = function() {
|
Server.prototype.closeIdleConnections = function closeIdleConnections() {
|
||||||
if (!this[kConnections]) {
|
if (!this[kConnections]) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -618,7 +619,8 @@ Server.prototype.setTimeout = function setTimeout(msecs, callback) {
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
Server.prototype[EE.captureRejectionSymbol] = function(err, event, ...args) {
|
Server.prototype[EE.captureRejectionSymbol] =
|
||||||
|
assignFunctionName(EE.captureRejectionSymbol, function(err, event, ...args) {
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case 'request': {
|
case 'request': {
|
||||||
const { 1: res } = args;
|
const { 1: res } = args;
|
||||||
@ -639,7 +641,7 @@ Server.prototype[EE.captureRejectionSymbol] = function(err, event, ...args) {
|
|||||||
net.Server.prototype[SymbolFor('nodejs.rejection')]
|
net.Server.prototype[SymbolFor('nodejs.rejection')]
|
||||||
.apply(this, arguments);
|
.apply(this, arguments);
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
|
||||||
function checkConnections() {
|
function checkConnections() {
|
||||||
if (this.headersTimeout === 0 && this.requestTimeout === 0) {
|
if (this.headersTimeout === 0 && this.requestTimeout === 0) {
|
||||||
|
@ -110,7 +110,7 @@ Server.prototype.closeIdleConnections = HttpServer.prototype.closeIdleConnection
|
|||||||
|
|
||||||
Server.prototype.setTimeout = HttpServer.prototype.setTimeout;
|
Server.prototype.setTimeout = HttpServer.prototype.setTimeout;
|
||||||
|
|
||||||
Server.prototype.close = function() {
|
Server.prototype.close = function close() {
|
||||||
httpServerPreClose(this);
|
httpServerPreClose(this);
|
||||||
ReflectApply(tls.Server.prototype.close, this, arguments);
|
ReflectApply(tls.Server.prototype.close, this, arguments);
|
||||||
return this;
|
return this;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user