Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions lib/_http_outgoing.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const {
hideStackFrames,
} = require('internal/errors');
const { validateString } = require('internal/validators');
const { assignFunctionName } = require('internal/util');
const { isUint8Array } = require('internal/util/types');

let debug = require('internal/util/debuglog').debuglog('http', (fn) => {
Expand Down Expand Up @@ -254,14 +255,14 @@ OutgoingMessage.prototype._renderHeaders = function _renderHeaders() {
return headers;
};

OutgoingMessage.prototype.cork = function() {
OutgoingMessage.prototype.cork = function cork() {
this[kCorked]++;
if (this[kSocket]) {
this[kSocket].cork();
}
};

OutgoingMessage.prototype.uncork = function() {
OutgoingMessage.prototype.uncork = function uncork() {
this[kCorked]--;
if (this[kSocket]) {
this[kSocket].uncork();
Expand Down Expand Up @@ -606,21 +607,21 @@ 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)) {
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) {
throw new ERR_HTTP_INVALID_HEADER_VALUE.HideStackFramesError(value, name);
}
if (checkInvalidHeaderChar(value)) {
debug('Header "%s" contains invalid characters', name);
throw new ERR_INVALID_CHAR.HideStackFramesError('header content', name);
}
});
}));

function parseUniqueHeadersOption(headers) {
if (!ArrayIsArray(headers)) {
Expand Down
16 changes: 9 additions & 7 deletions lib/_http_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ const {
},
} = require('internal/errors');
const {
assignFunctionName,
kEmptyObject,
promisify,
} = require('internal/util');
Expand Down Expand Up @@ -573,17 +574,17 @@ function Server(options, requestListener) {
ObjectSetPrototypeOf(Server.prototype, net.Server.prototype);
ObjectSetPrototypeOf(Server, net.Server);

Server.prototype.close = function() {
Server.prototype.close = function close() {
httpServerPreClose(this);
ReflectApply(net.Server.prototype.close, this, arguments);
return this;
};

Server.prototype[SymbolAsyncDispose] = async function() {
Server.prototype[SymbolAsyncDispose] = assignFunctionName(SymbolAsyncDispose, async function() {
return promisify(this.close).call(this);
};
});

Server.prototype.closeAllConnections = function() {
Server.prototype.closeAllConnections = function closeAllConnections() {
if (!this[kConnections]) {
return;
}
Expand All @@ -595,7 +596,7 @@ Server.prototype.closeAllConnections = function() {
}
};

Server.prototype.closeIdleConnections = function() {
Server.prototype.closeIdleConnections = function closeIdleConnections() {
if (!this[kConnections]) {
return;
}
Expand All @@ -618,7 +619,8 @@ Server.prototype.setTimeout = function setTimeout(msecs, callback) {
return this;
};

Server.prototype[EE.captureRejectionSymbol] = function(err, event, ...args) {
Server.prototype[EE.captureRejectionSymbol] =
assignFunctionName(EE.captureRejectionSymbol, function(err, event, ...args) {
Comment on lines +622 to +623
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linter seems to be happy with this but better suggestions would be appreciated.

switch (event) {
case 'request': {
const { 1: res } = args;
Expand All @@ -639,7 +641,7 @@ Server.prototype[EE.captureRejectionSymbol] = function(err, event, ...args) {
net.Server.prototype[SymbolFor('nodejs.rejection')]
.apply(this, arguments);
}
};
});

function checkConnections() {
if (this.headersTimeout === 0 && this.requestTimeout === 0) {
Expand Down
2 changes: 1 addition & 1 deletion lib/https.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ Server.prototype.closeIdleConnections = HttpServer.prototype.closeIdleConnection

Server.prototype.setTimeout = HttpServer.prototype.setTimeout;

Server.prototype.close = function() {
Server.prototype.close = function close() {
httpServerPreClose(this);
ReflectApply(tls.Server.prototype.close, this, arguments);
return this;
Expand Down
Loading