Skip to content

Commit

Permalink
http: reduce usage of public util
Browse files Browse the repository at this point in the history
PR-URL: nodejs#26548
Refs: nodejs#26546
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
ZYSzys authored and danbev committed Mar 12, 2019
1 parent c51735f commit 4c4e4f4
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
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

0 comments on commit 4c4e4f4

Please sign in to comment.