@@ -14,7 +14,7 @@ const Messenger = require('./core/messenger');
1414const DNSCacheHttpClient = require ( './core/dnscache_httpclient' ) ;
1515const HttpClient = require ( './core/httpclient' ) ;
1616const HttpClientNext = require ( './core/httpclient_next' ) ;
17- const { FetchFactory, safeFetch } = require ( './core/fetch_factory' ) ;
17+ const { FetchFactory, safeFetch, fetch } = require ( './core/fetch_factory' ) ;
1818const createLoggers = require ( './core/logger' ) ;
1919const Singleton = require ( './core/singleton' ) ;
2020const utils = require ( './core/utils' ) ;
@@ -54,11 +54,9 @@ class EggApplication extends EggCore {
5454 this . HttpClientNext = HttpClientNext ;
5555 this . FetchFactory = FetchFactory ;
5656 if ( FetchFactory ) {
57- this . FetchFactory . setClientOptions ( ) ;
58- this . fetch = FetchFactory . fetch ;
57+ this . fetch = fetch . bind ( this ) ;
5958 this . safeFetch = safeFetch . bind ( this ) ;
6059 }
61-
6260 this . loader . loadConfig ( ) ;
6361
6462 /**
@@ -297,11 +295,13 @@ class EggApplication extends EggCore {
297295 * Create a new HttpClient instance with custom options
298296 * @param {Object } [options] HttpClient init options
299297 */
300- createHttpClient ( options ) {
298+ createHttpClient ( options = { } ) {
301299 let httpClient ;
300+ options . lookup = options . lookup ?? this . config . httpclient . lookup ;
301+
302302 if ( this . config . httpclient . useHttpClientNext || this . config . httpclient . allowH2 ) {
303303 httpClient = new this . HttpClientNext ( this , options ) ;
304- } else if ( this . config . httpclient . enableDNSCache ) {
304+ } else if ( this . config . httpclient ? .enableDNSCache ) {
305305 httpClient = new DNSCacheHttpClient ( this , options ) ;
306306 } else {
307307 httpClient = new this . HttpClient ( this , options ) ;
@@ -495,7 +495,7 @@ class EggApplication extends EggCore {
495495 return this . config . env ;
496496 }
497497 /* eslint no-empty-function: off */
498- set env ( _ ) { }
498+ set env ( _ ) { }
499499
500500 /**
501501 * app.proxy delegate app.config.proxy
@@ -506,7 +506,7 @@ class EggApplication extends EggCore {
506506 return this . config . proxy ;
507507 }
508508 /* eslint no-empty-function: off */
509- set proxy ( _ ) { }
509+ set proxy ( _ ) { }
510510
511511 /**
512512 * create a singleton instance
0 commit comments