mirror of
https://github.com/grpc/grpc-node.git
synced 2026-02-01 14:54:35 +00:00
Merge pull request #2608 from swimmio/fix-proxy-connect-missing-port
Fix missing port in proxy CONNECT when using the default HTTPS port
This commit is contained in:
commit
993835a0ec
@ -30,6 +30,7 @@ import {
|
||||
import { ChannelOptions } from './channel-options';
|
||||
import { GrpcUri, parseUri, splitHostPort, uriToString } from './uri-parser';
|
||||
import { URL } from 'url';
|
||||
import { DEFAULT_PORT } from './resolver-dns';
|
||||
|
||||
const TRACER_NAME = 'proxy';
|
||||
|
||||
@ -189,12 +190,19 @@ export function getProxiedConnection(
|
||||
if (parsedTarget === null) {
|
||||
return Promise.resolve<ProxyConnectionResult>({});
|
||||
}
|
||||
const splitHostPost = splitHostPort(parsedTarget.path);
|
||||
if (splitHostPost === null) {
|
||||
return Promise.resolve<ProxyConnectionResult>({});
|
||||
}
|
||||
const hostPort = `${splitHostPost.host}:${
|
||||
splitHostPost.port ?? DEFAULT_PORT
|
||||
}`;
|
||||
const options: http.RequestOptions = {
|
||||
method: 'CONNECT',
|
||||
path: parsedTarget.path,
|
||||
path: hostPort,
|
||||
};
|
||||
const headers: http.OutgoingHttpHeaders = {
|
||||
Host: parsedTarget.path,
|
||||
Host: hostPort,
|
||||
};
|
||||
// Connect to the subchannel address as a proxy
|
||||
if (isTcpSubchannelAddress(address)) {
|
||||
|
||||
@ -43,7 +43,7 @@ function trace(text: string): void {
|
||||
/**
|
||||
* The default TCP port to connect to if not explicitly specified in the target.
|
||||
*/
|
||||
const DEFAULT_PORT = 443;
|
||||
export const DEFAULT_PORT = 443;
|
||||
|
||||
const DEFAULT_MIN_TIME_BETWEEN_RESOLUTIONS_MS = 30_000;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user