Skip to content

Commit 230352c

Browse files
committed
Revert "https: refactor to use http internals"
This reverts commit 5118f31. It is breaking code in the wild that depends on the original behavior to do tracing. I don't think we need to necessarily fix this in 8.x but we might want to reclassify the original commit as Semver Major Refs: #16395
1 parent 40d8211 commit 230352c

File tree

1 file changed

+17
-27
lines changed

1 file changed

+17
-27
lines changed

lib/https.js

+17-27
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,8 @@ require('internal/util').assertCrypto();
2525

2626
const tls = require('tls');
2727
const url = require('url');
28+
const http = require('http');
2829
const util = require('util');
29-
const { Agent: HttpAgent } = require('_http_agent');
30-
const {
31-
Server: HttpServer,
32-
_connectionListener
33-
} = require('_http_server');
34-
const { ClientRequest } = require('_http_client');
3530
const { inherits } = util;
3631
const debug = util.debuglog('https');
3732
const { urlToOptions, searchParamsSymbol } = require('internal/url');
@@ -56,7 +51,7 @@ function Server(opts, requestListener) {
5651
opts.ALPNProtocols = ['http/1.1'];
5752
}
5853

59-
tls.Server.call(this, opts, _connectionListener);
54+
tls.Server.call(this, opts, http._connectionListener);
6055

6156
this.httpAllowHalfOpen = false;
6257

@@ -73,12 +68,13 @@ function Server(opts, requestListener) {
7368
this.keepAliveTimeout = 5000;
7469
}
7570
inherits(Server, tls.Server);
71+
exports.Server = Server;
7672

77-
Server.prototype.setTimeout = HttpServer.prototype.setTimeout;
73+
Server.prototype.setTimeout = http.Server.prototype.setTimeout;
7874

79-
function createServer(opts, requestListener) {
75+
exports.createServer = function createServer(opts, requestListener) {
8076
return new Server(opts, requestListener);
81-
}
77+
};
8278

8379

8480
// HTTPS agents.
@@ -133,7 +129,7 @@ function Agent(options) {
133129
if (!(this instanceof Agent))
134130
return new Agent(options);
135131

136-
HttpAgent.call(this, options);
132+
http.Agent.call(this, options);
137133
this.defaultPort = 443;
138134
this.protocol = 'https:';
139135
this.maxCachedSessions = this.options.maxCachedSessions;
@@ -145,11 +141,11 @@ function Agent(options) {
145141
list: []
146142
};
147143
}
148-
inherits(Agent, HttpAgent);
144+
inherits(Agent, http.Agent);
149145
Agent.prototype.createConnection = createConnection;
150146

151147
Agent.prototype.getName = function getName(options) {
152-
var name = HttpAgent.prototype.getName.call(this, options);
148+
var name = http.Agent.prototype.getName.call(this, options);
153149

154150
name += ':';
155151
if (options.ca)
@@ -223,7 +219,10 @@ Agent.prototype._evictSession = function _evictSession(key) {
223219

224220
const globalAgent = new Agent();
225221

226-
function request(options, cb) {
222+
exports.globalAgent = globalAgent;
223+
exports.Agent = Agent;
224+
225+
exports.request = function request(options, cb) {
227226
if (typeof options === 'string') {
228227
options = url.parse(options);
229228
if (!options.hostname) {
@@ -237,20 +236,11 @@ function request(options, cb) {
237236
options = util._extend({}, options);
238237
}
239238
options._defaultAgent = globalAgent;
240-
return new ClientRequest(options, cb);
241-
}
239+
return http.request(options, cb);
240+
};
242241

243-
function get(options, cb) {
244-
const req = request(options, cb);
242+
exports.get = function get(options, cb) {
243+
var req = exports.request(options, cb);
245244
req.end();
246245
return req;
247-
}
248-
249-
module.exports = {
250-
Agent,
251-
globalAgent,
252-
Server,
253-
createServer,
254-
get,
255-
request
256246
};

0 commit comments

Comments
 (0)