Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions packages/grpc-js/src/http_proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion packages/grpc-js/src/resolver-dns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down