File tree Expand file tree Collapse file tree 3 files changed +17
-12
lines changed Expand file tree Collapse file tree 3 files changed +17
-12
lines changed Original file line number Diff line number Diff line change @@ -257,7 +257,7 @@ export function getContentLengthAfterModification(
257
257
// based on the given config
258
258
export function shouldUseStrictHttps (
259
259
hostname : string ,
260
- port : string ,
260
+ port : number ,
261
261
ignoreHostHttpsErrors : string [ ] | boolean
262
262
) {
263
263
let skipHttpsErrors = false ;
Original file line number Diff line number Diff line change @@ -639,10 +639,18 @@ export class PassThroughHandler extends PassThroughHandlerDefinition {
639
639
rawHeaders = objectHeadersToRaw ( headers ) ;
640
640
}
641
641
642
- const strictHttpsChecks = shouldUseStrictHttps ( hostname ! , port ! , this . ignoreHostHttpsErrors ) ;
642
+ const effectivePort = ! ! port
643
+ ? parseInt ( port , 10 )
644
+ : ( protocol === 'https:' ? 443 : 80 ) ;
645
+
646
+ const strictHttpsChecks = shouldUseStrictHttps (
647
+ hostname ! ,
648
+ effectivePort ! ,
649
+ this . ignoreHostHttpsErrors
650
+ ) ;
643
651
644
652
// Use a client cert if it's listed for the host+port or whole hostname
645
- const hostWithPort = `${ hostname } :${ port } ` ;
653
+ const hostWithPort = `${ hostname } :${ effectivePort } ` ;
646
654
const clientCert = this . clientCertificateHostMap [ hostWithPort ] ||
647
655
this . clientCertificateHostMap [ hostname ! ] ||
648
656
{ } ;
@@ -656,10 +664,6 @@ export class PassThroughHandler extends PassThroughHandlerDefinition {
656
664
// and we can't use ALPN to detect HTTP/2 support cleanly.
657
665
let shouldTryH2Upstream = isH2Downstream && protocol === 'https:' ;
658
666
659
- const effectivePort = ! ! port
660
- ? parseInt ( port , 10 )
661
- : ( protocol === 'https:' ? 443 : 80 ) ;
662
-
663
667
let family : undefined | 4 | 6 ;
664
668
if ( hostname === 'localhost' ) {
665
669
// Annoying special case: some localhost servers listen only on either ipv4 or ipv6.
Original file line number Diff line number Diff line change @@ -292,9 +292,14 @@ export class PassThroughWebSocketHandler extends PassThroughWebSocketHandlerDefi
292
292
head : Buffer
293
293
) {
294
294
const parsedUrl = url . parse ( wsUrl ) ;
295
+
296
+ const effectivePort = ! ! parsedUrl . port
297
+ ? parseInt ( parsedUrl . port , 10 )
298
+ : parsedUrl . protocol == 'wss:' ? 443 : 80 ;
299
+
295
300
const checkServerCertificate = shouldUseStrictHttps (
296
301
parsedUrl . hostname ! ,
297
- parsedUrl . port ! ,
302
+ effectivePort ,
298
303
this . ignoreHostHttpsErrors
299
304
) ;
300
305
@@ -303,10 +308,6 @@ export class PassThroughWebSocketHandler extends PassThroughWebSocketHandlerDefi
303
308
? { ca : trustedCerts }
304
309
: { } ;
305
310
306
- const effectivePort = ! ! parsedUrl . port
307
- ? parseInt ( parsedUrl . port , 10 )
308
- : parsedUrl . protocol == 'wss:' ? 443 : 80 ;
309
-
310
311
const proxySettingSource = assertParamDereferenced ( this . proxyConfig ) as ProxySettingSource ;
311
312
312
313
const agent = await getAgent ( {
You can’t perform that action at this time.
0 commit comments