@@ -32,7 +32,7 @@ export function connectProxyResolver(
32
32
const doUseHostProxy = typeof useHostProxy === 'boolean' ? useHostProxy : ! initData . remote . isRemote ;
33
33
const params : ProxyAgentParams = {
34
34
resolveProxy : url => extHostWorkspace . resolveProxy ( url ) ,
35
- lookupProxyAuthorization : lookupProxyAuthorization . bind ( undefined , extHostLogService , configProvider , { } , { } ) ,
35
+ lookupProxyAuthorization : lookupProxyAuthorization . bind ( undefined , extHostLogService , configProvider , { } ) ,
36
36
getProxyURL : ( ) => configProvider . getConfiguration ( 'http' ) . get ( 'proxy' ) ,
37
37
getProxySupport : ( ) => configProvider . getConfiguration ( 'http' ) . get < ProxySupportSetting > ( 'proxySupport' ) || 'off' ,
38
38
getSystemCertificatesV1 : ( ) => certSettingV1 ( configProvider ) ,
@@ -121,9 +121,9 @@ async function lookupProxyAuthorization(
121
121
extHostLogService : ILogService ,
122
122
configProvider : ExtHostConfigProvider ,
123
123
proxyAuthenticateCache : Record < string , string | string [ ] | undefined > ,
124
- pendingLookups : Record < string , Promise < string | undefined > > ,
125
124
proxyURL : string ,
126
- proxyAuthenticate ?: string | string [ ]
125
+ proxyAuthenticate : string | string [ ] | undefined ,
126
+ state : { kerberosRequested ?: boolean }
127
127
) : Promise < string | undefined > {
128
128
const cached = proxyAuthenticateCache [ proxyURL ] ;
129
129
if ( proxyAuthenticate ) {
@@ -132,25 +132,20 @@ async function lookupProxyAuthorization(
132
132
extHostLogService . trace ( 'ProxyResolver#lookupProxyAuthorization callback' , `proxyURL:${ proxyURL } ` , `proxyAuthenticate:${ proxyAuthenticate } ` , `proxyAuthenticateCache:${ cached } ` ) ;
133
133
const header = proxyAuthenticate || cached ;
134
134
const authenticate = Array . isArray ( header ) ? header : typeof header === 'string' ? [ header ] : [ ] ;
135
- if ( authenticate . some ( a => / ^ ( N e g o t i a t e | K e r b e r o s ) ( | $ ) / i. test ( a ) ) ) {
136
- const lookupKey = `${ proxyURL } :Negotiate` ;
137
- return pendingLookups [ lookupKey ] ??= ( async ( ) => {
138
- try {
139
- const kerberos = await import ( 'kerberos' ) ;
140
- const url = new URL ( proxyURL ) ;
141
- const spn = configProvider . getConfiguration ( 'http' ) . get < string > ( 'proxyKerberosServicePrincipal' )
142
- || ( process . platform === 'win32' ? `HTTP/${ url . hostname } ` : `HTTP@${ url . hostname } ` ) ;
143
- extHostLogService . debug ( 'ProxyResolver#lookupProxyAuthorization Kerberos authentication lookup' , `proxyURL:${ proxyURL } ` , `spn:${ spn } ` ) ;
144
- const client = await kerberos . initializeClient ( spn ) ;
145
- const response = await client . step ( '' ) ;
146
- return 'Negotiate ' + response ;
147
- } catch ( err ) {
148
- extHostLogService . error ( 'ProxyResolver#lookupProxyAuthorization Kerberos authentication failed' , err ) ;
149
- return undefined ;
150
- } finally {
151
- delete pendingLookups [ lookupKey ] ;
152
- }
153
- } ) ( ) ;
135
+ if ( authenticate . some ( a => / ^ ( N e g o t i a t e | K e r b e r o s ) ( | $ ) / i. test ( a ) ) && ! state . kerberosRequested ) {
136
+ try {
137
+ state . kerberosRequested = true ;
138
+ const kerberos = await import ( 'kerberos' ) ;
139
+ const url = new URL ( proxyURL ) ;
140
+ const spn = configProvider . getConfiguration ( 'http' ) . get < string > ( 'proxyKerberosServicePrincipal' )
141
+ || ( process . platform === 'win32' ? `HTTP/${ url . hostname } ` : `HTTP@${ url . hostname } ` ) ;
142
+ extHostLogService . debug ( 'ProxyResolver#lookupProxyAuthorization Kerberos authentication lookup' , `proxyURL:${ proxyURL } ` , `spn:${ spn } ` ) ;
143
+ const client = await kerberos . initializeClient ( spn ) ;
144
+ const response = await client . step ( '' ) ;
145
+ return 'Negotiate ' + response ;
146
+ } catch ( err ) {
147
+ extHostLogService . error ( 'ProxyResolver#lookupProxyAuthorization Kerberos authentication failed' , err ) ;
148
+ }
154
149
}
155
150
return undefined ;
156
151
}
0 commit comments