Skip to content

Commit cd77811

Browse files
ZYSzysrefack
authored andcommitted
http: reduce usage of public util
PR-URL: #26548 Refs: #26546 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent b581bb0 commit cd77811

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

lib/_http_agent.js

Lines changed: 3 additions & 3 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.
@@ -106,7 +105,8 @@ function Agent(options) {
106105
});
107106
}
108107

109-
util.inherits(Agent, EventEmitter);
108+
Object.setPrototypeOf(Agent.prototype, EventEmitter.prototype);
109+
Object.setPrototypeOf(Agent, EventEmitter);
110110

111111
Agent.defaultMaxSockets = Infinity;
112112

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: 2 additions & 2 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');
@@ -104,7 +103,8 @@ function OutgoingMessage() {
104103

105104
this._onPendingData = noopPendingOutput;
106105
}
107-
util.inherits(OutgoingMessage, Stream);
106+
Object.setPrototypeOf(OutgoingMessage.prototype, Stream.prototype);
107+
Object.setPrototypeOf(OutgoingMessage, Stream);
108108

109109

110110
Object.defineProperty(OutgoingMessage.prototype, '_headers', {

lib/_http_server.js

Lines changed: 4 additions & 3 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 {
@@ -136,7 +135,8 @@ function ServerResponse(req) {
136135
this.shouldKeepAlive = false;
137136
}
138137
}
139-
util.inherits(ServerResponse, OutgoingMessage);
138+
Object.setPrototypeOf(ServerResponse.prototype, OutgoingMessage.prototype);
139+
Object.setPrototypeOf(ServerResponse, OutgoingMessage);
140140

141141
ServerResponse.prototype._finish = function _finish() {
142142
DTRACE_HTTP_SERVER_RESPONSE(this.connection);
@@ -306,7 +306,8 @@ function Server(options, requestListener) {
306306
this.maxHeadersCount = null;
307307
this.headersTimeout = 40 * 1000; // 40 seconds
308308
}
309-
util.inherits(Server, net.Server);
309+
Object.setPrototypeOf(Server.prototype, net.Server.prototype);
310+
Object.setPrototypeOf(Server, net.Server);
310311

311312

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

0 commit comments

Comments
 (0)