@@ -62,16 +62,17 @@ function fixModule(requestedName, filename, loadedModule) {
6262 fixModule ( modDetails . requestedName , modDetails . filename , modDetails . loadedModule ) ;
6363 } ) ;
6464 delayedInterception = false ;
65- } else if ( requestedName === 'axios' ) {
66- // Disable built-in proxy support, to let global-agent/ tunnel take precedence
65+ } else if ( requestedName === 'axios' && ! global . GLOBAL_AGENT ) {
66+ // Disable built-in proxy support, to let global-tunnel take precedence
6767 // Supported back to the very first release of Axios
6868 fixedModule . defaults . proxy = false ;
6969 } else if (
7070 requestedName === 'request' &&
71+ ! global . GLOBAL_AGENT && // Works automatically with global-agent
7172 loadedModule . defaults && // Request >= 2.17 (before that, proxy support isn't a problem anyway)
7273 ! loadedModule . INTERCEPTED_BY_HTTPTOOLKIT // Make this idempotent
7374 ) {
74- // Disable built-in proxy support, to let global-agent/ tunnel take precedence
75+ // Disable built-in proxy support, to let global-tunnel take precedence
7576 fixedModule = loadedModule . defaults ( { proxy : false } ) ;
7677 fixedModule . INTERCEPTED_BY_HTTPTOOLKIT = true ;
7778 } else if (
@@ -92,20 +93,15 @@ function fixModule(requestedName, filename, loadedModule) {
9293 }
9394 return originalRequestMethod . apply ( this , arguments ) ;
9495 } ;
95- } else if ( requestedName === 'stripe' && ! loadedModule . INTERCEPTED_BY_HTTPTOOLKIT ) {
96+ } else if (
97+ requestedName === 'stripe' &&
98+ ! loadedModule . INTERCEPTED_BY_HTTPTOOLKIT
99+ ) {
96100 fixedModule = Object . assign ( function ( ) {
97101 const result = loadedModule . apply ( this , arguments ) ;
98102
99- if ( global . GLOBAL_AGENT ) {
100- // Set by global-agent in Node 10+
101- // This won't actually work until https://github.com/gajus/global-agent/pull/13
102- // is somehow resolved, one way or another.
103- result . setHttpAgent ( global . GLOBAL_AGENT . HTTPS_PROXY_AGENT ) ;
104- } else {
105- // Set by global-tunnel in Node < 10 (or global-agent in 11.7+)
106- result . setHttpAgent ( require ( 'https' ) . globalAgent ) ;
107- }
108-
103+ // Set by global-tunnel in Node < 10 (or global-agent in 11.7+)
104+ result . setHttpAgent ( require ( 'https' ) . globalAgent ) ;
109105 return result ;
110106 } , fixedModule ) ;
111107 fixedModule . INTERCEPTED_BY_HTTPTOOLKIT = true ;
0 commit comments