Skip to content

Commit 0854192

Browse files
committed
Review fixes
1 parent 1f148e9 commit 0854192

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

packages/grpc-js/src/http_proxy.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import {
3030
import { ChannelOptions } from './channel-options';
3131
import { GrpcUri, parseUri, splitHostPort, uriToString } from './uri-parser';
3232
import { URL } from 'url';
33+
import { DEFAULT_PORT } from './resolver-dns';
3334

3435
const TRACER_NAME = 'proxy';
3536

@@ -189,16 +190,19 @@ export function getProxiedConnection(
189190
if (parsedTarget === null) {
190191
return Promise.resolve<ProxyConnectionResult>({});
191192
}
192-
const targetHostPost = splitHostPort(parsedTarget.path);
193-
if (targetHostPost === null) {
193+
const splitHostPost = splitHostPort(parsedTarget.path);
194+
if (splitHostPost === null) {
194195
return Promise.resolve<ProxyConnectionResult>({});
195196
}
197+
const hostPort = `${splitHostPost.host}:${
198+
splitHostPost.port ?? DEFAULT_PORT
199+
}`;
196200
const options: http.RequestOptions = {
197201
method: 'CONNECT',
198-
path: targetHostPost.host + ':' + (targetHostPost.port != null ? targetHostPost.port : '443'),
202+
path: hostPort,
199203
};
200204
const headers: http.OutgoingHttpHeaders = {
201-
Host: targetHostPost.host + ':' + (targetHostPost.port != null ? targetHostPost.port : '443'),
205+
Host: hostPort,
202206
};
203207
// Connect to the subchannel address as a proxy
204208
if (isTcpSubchannelAddress(address)) {

packages/grpc-js/src/resolver-dns.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function trace(text: string): void {
4343
/**
4444
* The default TCP port to connect to if not explicitly specified in the target.
4545
*/
46-
const DEFAULT_PORT = 443;
46+
export const DEFAULT_PORT = 443;
4747

4848
const DEFAULT_MIN_TIME_BETWEEN_RESOLUTIONS_MS = 30_000;
4949

0 commit comments

Comments
 (0)