@@ -25,9 +25,14 @@ require('internal/util').assertCrypto();
2525
2626const  tls  =  require ( 'tls' ) ; 
2727const  url  =  require ( 'url' ) ; 
28- const  http  =  require ( 'http' ) ; 
2928const  util  =  require ( 'util' ) ; 
30- const  inherits  =  util . inherits ; 
29+ const  {  Agent : HttpAgent  }  =  require ( '_http_agent' ) ; 
30+ const  { 
31+   Server : HttpServer , 
32+   _connectionListener
33+ }  =  require ( '_http_server' ) ; 
34+ const  {  ClientRequest }  =  require ( '_http_client' ) ; 
35+ const  {  inherits }  =  util ; 
3136const  debug  =  util . debuglog ( 'https' ) ; 
3237const  {  urlToOptions,  searchParamsSymbol }  =  require ( 'internal/url' ) ; 
3338
@@ -51,7 +56,7 @@ function Server(opts, requestListener) {
5156    opts . ALPNProtocols  =  [ 'http/1.1' ] ; 
5257  } 
5358
54-   tls . Server . call ( this ,  opts ,  http . _connectionListener ) ; 
59+   tls . Server . call ( this ,  opts ,  _connectionListener ) ; 
5560
5661  this . httpAllowHalfOpen  =  false ; 
5762
@@ -68,13 +73,12 @@ function Server(opts, requestListener) {
6873  this . keepAliveTimeout  =  5000 ; 
6974} 
7075inherits ( Server ,  tls . Server ) ; 
71- exports . Server  =  Server ; 
7276
73- Server . prototype . setTimeout  =  http . Server . prototype . setTimeout ; 
77+ Server . prototype . setTimeout  =  HttpServer . prototype . setTimeout ; 
7478
75- exports . createServer   =   function  createServer ( opts ,  requestListener )  { 
79+ function  createServer ( opts ,  requestListener )  { 
7680  return  new  Server ( opts ,  requestListener ) ; 
77- } ; 
81+ } 
7882
7983
8084// HTTPS agents. 
@@ -129,7 +133,7 @@ function Agent(options) {
129133  if  ( ! ( this  instanceof  Agent ) ) 
130134    return  new  Agent ( options ) ; 
131135
132-   http . Agent . call ( this ,  options ) ; 
136+   HttpAgent . call ( this ,  options ) ; 
133137  this . defaultPort  =  443 ; 
134138  this . protocol  =  'https:' ; 
135139  this . maxCachedSessions  =  this . options . maxCachedSessions ; 
@@ -141,11 +145,11 @@ function Agent(options) {
141145    list : [ ] 
142146  } ; 
143147} 
144- inherits ( Agent ,  http . Agent ) ; 
148+ inherits ( Agent ,  HttpAgent ) ; 
145149Agent . prototype . createConnection  =  createConnection ; 
146150
147151Agent . prototype . getName  =  function  getName ( options )  { 
148-   var  name  =  http . Agent . prototype . getName . call ( this ,  options ) ; 
152+   var  name  =  HttpAgent . prototype . getName . call ( this ,  options ) ; 
149153
150154  name  +=  ':' ; 
151155  if  ( options . ca ) 
@@ -219,10 +223,7 @@ Agent.prototype._evictSession = function _evictSession(key) {
219223
220224const  globalAgent  =  new  Agent ( ) ; 
221225
222- exports . globalAgent  =  globalAgent ; 
223- exports . Agent  =  Agent ; 
224- 
225- exports . request  =  function  request ( options ,  cb )  { 
226+ function  request ( options ,  cb )  { 
226227  if  ( typeof  options  ===  'string' )  { 
227228    options  =  url . parse ( options ) ; 
228229    if  ( ! options . hostname )  { 
@@ -236,11 +237,20 @@ exports.request = function request(options, cb) {
236237    options  =  util . _extend ( { } ,  options ) ; 
237238  } 
238239  options . _defaultAgent  =  globalAgent ; 
239-   return  http . request ( options ,  cb ) ; 
240- } ; 
240+   return  new   ClientRequest ( options ,  cb ) ; 
241+ } 
241242
242- exports . get   =   function  get ( options ,  cb )  { 
243-   var  req  =  exports . request ( options ,  cb ) ; 
243+ function  get ( options ,  cb )  { 
244+   const  req  =  request ( options ,  cb ) ; 
244245  req . end ( ) ; 
245246  return  req ; 
247+ } 
248+ 
249+ module . exports  =  { 
250+   Agent, 
251+   globalAgent, 
252+   Server, 
253+   createServer, 
254+   get, 
255+   request
246256} ; 
0 commit comments