Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http: reduce usage of public util #26548

Closed
wants to merge 1 commit into from
Closed
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
3 changes: 1 addition & 2 deletions lib/_http_agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@
'use strict';

const net = require('net');
const util = require('util');
const EventEmitter = require('events');
const debug = util.debuglog('http');
const debug = require('internal/util/debuglog').debuglog('http');
const { async_id_symbol } = require('internal/async_hooks').symbols;

// New Agent code.
Expand Down
2 changes: 1 addition & 1 deletion lib/_http_common.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const {
readStop
} = incoming;

const debug = require('util').debuglog('http');
const debug = require('internal/util/debuglog').debuglog('http');

const kIncomingMessage = Symbol('IncomingMessage');
const kOnHeaders = HTTPParser.kOnHeaders | 0;
Expand Down
9 changes: 4 additions & 5 deletions lib/_http_outgoing.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

const assert = require('internal/assert');
const Stream = require('stream');
const util = require('util');
const internalUtil = require('internal/util');
const { outHeadersKey, utcDate } = require('internal/http');
const { Buffer } = require('buffer');
Expand Down Expand Up @@ -109,10 +108,10 @@ Object.setPrototypeOf(OutgoingMessage, Stream);


Object.defineProperty(OutgoingMessage.prototype, '_headers', {
get: util.deprecate(function() {
get: internalUtil.deprecate(function() {
return this.getHeaders();
}, 'OutgoingMessage.prototype._headers is deprecated', 'DEP0066'),
set: util.deprecate(function(val) {
set: internalUtil.deprecate(function(val) {
if (val == null) {
this[outHeadersKey] = null;
} else if (typeof val === 'object') {
Expand All @@ -127,7 +126,7 @@ Object.defineProperty(OutgoingMessage.prototype, '_headers', {
});

Object.defineProperty(OutgoingMessage.prototype, '_headerNames', {
get: util.deprecate(function() {
get: internalUtil.deprecate(function() {
const headers = this[outHeadersKey];
if (headers !== null) {
const out = Object.create(null);
Expand All @@ -141,7 +140,7 @@ Object.defineProperty(OutgoingMessage.prototype, '_headerNames', {
}
return null;
}, 'OutgoingMessage.prototype._headerNames is deprecated', 'DEP0066'),
set: util.deprecate(function(val) {
set: internalUtil.deprecate(function(val) {
if (typeof val === 'object' && val !== null) {
const headers = this[outHeadersKey];
if (!headers)
Expand Down
4 changes: 2 additions & 2 deletions lib/_http_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

'use strict';

const util = require('util');
const net = require('net');
const assert = require('internal/assert');
const {
Expand Down Expand Up @@ -310,7 +309,8 @@ function Server(options, requestListener) {
this.maxHeadersCount = null;
this.headersTimeout = 40 * 1000; // 40 seconds
}
util.inherits(Server, net.Server);
Object.setPrototypeOf(Server.prototype, net.Server.prototype);
Object.setPrototypeOf(Server, net.Server);


Server.prototype.setTimeout = function setTimeout(msecs, callback) {
Expand Down