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(
257257// based on the given config
258258export function shouldUseStrictHttps (
259259 hostname : string ,
260- port : string ,
260+ port : number ,
261261 ignoreHostHttpsErrors : string [ ] | boolean
262262) {
263263 let skipHttpsErrors = false ;
Original file line number Diff line number Diff line change @@ -639,10 +639,18 @@ export class PassThroughHandler extends PassThroughHandlerDefinition {
639639 rawHeaders = objectHeadersToRaw ( headers ) ;
640640 }
641641
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+ ) ;
643651
644652 // 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 } ` ;
646654 const clientCert = this . clientCertificateHostMap [ hostWithPort ] ||
647655 this . clientCertificateHostMap [ hostname ! ] ||
648656 { } ;
@@ -656,10 +664,6 @@ export class PassThroughHandler extends PassThroughHandlerDefinition {
656664 // and we can't use ALPN to detect HTTP/2 support cleanly.
657665 let shouldTryH2Upstream = isH2Downstream && protocol === 'https:' ;
658666
659- const effectivePort = ! ! port
660- ? parseInt ( port , 10 )
661- : ( protocol === 'https:' ? 443 : 80 ) ;
662-
663667 let family : undefined | 4 | 6 ;
664668 if ( hostname === 'localhost' ) {
665669 // 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
292292 head : Buffer
293293 ) {
294294 const parsedUrl = url . parse ( wsUrl ) ;
295+
296+ const effectivePort = ! ! parsedUrl . port
297+ ? parseInt ( parsedUrl . port , 10 )
298+ : parsedUrl . protocol == 'wss:' ? 443 : 80 ;
299+
295300 const checkServerCertificate = shouldUseStrictHttps (
296301 parsedUrl . hostname ! ,
297- parsedUrl . port ! ,
302+ effectivePort ,
298303 this . ignoreHostHttpsErrors
299304 ) ;
300305
@@ -303,10 +308,6 @@ export class PassThroughWebSocketHandler extends PassThroughWebSocketHandlerDefi
303308 ? { ca : trustedCerts }
304309 : { } ;
305310
306- const effectivePort = ! ! parsedUrl . port
307- ? parseInt ( parsedUrl . port , 10 )
308- : parsedUrl . protocol == 'wss:' ? 443 : 80 ;
309-
310311 const proxySettingSource = assertParamDereferenced ( this . proxyConfig ) as ProxySettingSource ;
311312
312313 const agent = await getAgent ( {
You can’t perform that action at this time.
0 commit comments