Skip to content

Commit 4c4e4f4

Browse files
ZYSzysdanbev
authored andcommitted
http: reduce usage of public util
PR-URL: #26548 Refs: #26546 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent c51735f commit 4c4e4f4

File tree

4 files changed

+8
-10
lines changed

4 files changed

+8
-10
lines changed

lib/_http_agent.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@
2222
'use strict';
2323

2424
const net = require('net');
25-
const util = require('util');
2625
const EventEmitter = require('events');
27-
const debug = util.debuglog('http');
26+
const debug = require('internal/util/debuglog').debuglog('http');
2827
const { async_id_symbol } = require('internal/async_hooks').symbols;
2928

3029
// New Agent code.

lib/_http_common.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const {
3636
readStop
3737
} = incoming;
3838

39-
const debug = require('util').debuglog('http');
39+
const debug = require('internal/util/debuglog').debuglog('http');
4040

4141
const kIncomingMessage = Symbol('IncomingMessage');
4242
const kOnHeaders = HTTPParser.kOnHeaders | 0;

lib/_http_outgoing.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
const assert = require('internal/assert');
2525
const Stream = require('stream');
26-
const util = require('util');
2726
const internalUtil = require('internal/util');
2827
const { outHeadersKey, utcDate } = require('internal/http');
2928
const { Buffer } = require('buffer');
@@ -109,10 +108,10 @@ Object.setPrototypeOf(OutgoingMessage, Stream);
109108

110109

111110
Object.defineProperty(OutgoingMessage.prototype, '_headers', {
112-
get: util.deprecate(function() {
111+
get: internalUtil.deprecate(function() {
113112
return this.getHeaders();
114113
}, 'OutgoingMessage.prototype._headers is deprecated', 'DEP0066'),
115-
set: util.deprecate(function(val) {
114+
set: internalUtil.deprecate(function(val) {
116115
if (val == null) {
117116
this[outHeadersKey] = null;
118117
} else if (typeof val === 'object') {
@@ -127,7 +126,7 @@ Object.defineProperty(OutgoingMessage.prototype, '_headers', {
127126
});
128127

129128
Object.defineProperty(OutgoingMessage.prototype, '_headerNames', {
130-
get: util.deprecate(function() {
129+
get: internalUtil.deprecate(function() {
131130
const headers = this[outHeadersKey];
132131
if (headers !== null) {
133132
const out = Object.create(null);
@@ -141,7 +140,7 @@ Object.defineProperty(OutgoingMessage.prototype, '_headerNames', {
141140
}
142141
return null;
143142
}, 'OutgoingMessage.prototype._headerNames is deprecated', 'DEP0066'),
144-
set: util.deprecate(function(val) {
143+
set: internalUtil.deprecate(function(val) {
145144
if (typeof val === 'object' && val !== null) {
146145
const headers = this[outHeadersKey];
147146
if (!headers)

lib/_http_server.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
'use strict';
2323

24-
const util = require('util');
2524
const net = require('net');
2625
const assert = require('internal/assert');
2726
const {
@@ -310,7 +309,8 @@ function Server(options, requestListener) {
310309
this.maxHeadersCount = null;
311310
this.headersTimeout = 40 * 1000; // 40 seconds
312311
}
313-
util.inherits(Server, net.Server);
312+
Object.setPrototypeOf(Server.prototype, net.Server.prototype);
313+
Object.setPrototypeOf(Server, net.Server);
314314

315315

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

0 commit comments

Comments
 (0)