@@ -25,8 +25,13 @@ require('internal/util').assertCrypto();
25
25
26
26
const tls = require ( 'tls' ) ;
27
27
const url = require ( 'url' ) ;
28
- const http = require ( 'http' ) ;
29
28
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' ) ;
30
35
const { inherits } = util ;
31
36
const debug = util . debuglog ( 'https' ) ;
32
37
const { urlToOptions, searchParamsSymbol } = require ( 'internal/url' ) ;
@@ -52,7 +57,7 @@ function Server(opts, requestListener) {
52
57
opts . ALPNProtocols = [ 'http/1.1' ] ;
53
58
}
54
59
55
- tls . Server . call ( this , opts , http . _connectionListener ) ;
60
+ tls . Server . call ( this , opts , _connectionListener ) ;
56
61
57
62
this . httpAllowHalfOpen = false ;
58
63
@@ -69,13 +74,12 @@ function Server(opts, requestListener) {
69
74
this . keepAliveTimeout = 5000 ;
70
75
}
71
76
inherits ( Server , tls . Server ) ;
72
- exports . Server = Server ;
73
77
74
- Server . prototype . setTimeout = http . Server . prototype . setTimeout ;
78
+ Server . prototype . setTimeout = HttpServer . prototype . setTimeout ;
75
79
76
- exports . createServer = function createServer ( opts , requestListener ) {
80
+ function createServer ( opts , requestListener ) {
77
81
return new Server ( opts , requestListener ) ;
78
- } ;
82
+ }
79
83
80
84
81
85
// HTTPS agents.
@@ -130,7 +134,7 @@ function Agent(options) {
130
134
if ( ! ( this instanceof Agent ) )
131
135
return new Agent ( options ) ;
132
136
133
- http . Agent . call ( this , options ) ;
137
+ HttpAgent . call ( this , options ) ;
134
138
this . defaultPort = 443 ;
135
139
this . protocol = 'https:' ;
136
140
this . maxCachedSessions = this . options . maxCachedSessions ;
@@ -142,11 +146,11 @@ function Agent(options) {
142
146
list : [ ]
143
147
} ;
144
148
}
145
- inherits ( Agent , http . Agent ) ;
149
+ inherits ( Agent , HttpAgent ) ;
146
150
Agent . prototype . createConnection = createConnection ;
147
151
148
152
Agent . prototype . getName = function getName ( options ) {
149
- var name = http . Agent . prototype . getName . call ( this , options ) ;
153
+ var name = HttpAgent . prototype . getName . call ( this , options ) ;
150
154
151
155
name += ':' ;
152
156
if ( options . ca )
@@ -220,10 +224,7 @@ Agent.prototype._evictSession = function _evictSession(key) {
220
224
221
225
const globalAgent = new Agent ( ) ;
222
226
223
- exports . globalAgent = globalAgent ;
224
- exports . Agent = Agent ;
225
-
226
- exports . request = function request ( options , cb ) {
227
+ function request ( options , cb ) {
227
228
if ( typeof options === 'string' ) {
228
229
options = url . parse ( options ) ;
229
230
if ( ! options . hostname ) {
@@ -237,11 +238,20 @@ exports.request = function request(options, cb) {
237
238
options = util . _extend ( { } , options ) ;
238
239
}
239
240
options . _defaultAgent = globalAgent ;
240
- return http . request ( options , cb ) ;
241
- } ;
241
+ return new ClientRequest ( options , cb ) ;
242
+ }
242
243
243
- exports . get = function get ( options , cb ) {
244
- var req = exports . request ( options , cb ) ;
244
+ function get ( options , cb ) {
245
+ const req = request ( options , cb ) ;
245
246
req . end ( ) ;
246
247
return req ;
248
+ }
249
+
250
+ module . exports = {
251
+ Agent,
252
+ globalAgent,
253
+ Server,
254
+ createServer,
255
+ get,
256
+ request
247
257
} ;
0 commit comments