mirror of https://github.com/grpc/grpc-node.git
Merge pull request #1902 from murgatroid99/grpc-js_http_proxy_fix_1.4
grpc-js: adds sometimes required Host header to proxy connection
This commit is contained in:
commit
a08e43d468
|
@ -190,6 +190,9 @@ export function getProxiedConnection(
|
||||||
method: 'CONNECT',
|
method: 'CONNECT',
|
||||||
path: parsedTarget.path,
|
path: parsedTarget.path,
|
||||||
};
|
};
|
||||||
|
const headers: http.OutgoingHttpHeaders = {
|
||||||
|
Host: parsedTarget.path,
|
||||||
|
};
|
||||||
// Connect to the subchannel address as a proxy
|
// Connect to the subchannel address as a proxy
|
||||||
if (isTcpSubchannelAddress(address)) {
|
if (isTcpSubchannelAddress(address)) {
|
||||||
options.host = address.host;
|
options.host = address.host;
|
||||||
|
@ -198,14 +201,13 @@ export function getProxiedConnection(
|
||||||
options.socketPath = address.path;
|
options.socketPath = address.path;
|
||||||
}
|
}
|
||||||
if ('grpc.http_connect_creds' in channelOptions) {
|
if ('grpc.http_connect_creds' in channelOptions) {
|
||||||
options.headers = {
|
headers['Proxy-Authorization'] =
|
||||||
'Proxy-Authorization':
|
'Basic ' +
|
||||||
'Basic ' +
|
Buffer.from(
|
||||||
Buffer.from(
|
channelOptions['grpc.http_connect_creds'] as string
|
||||||
channelOptions['grpc.http_connect_creds'] as string
|
).toString('base64');
|
||||||
).toString('base64'),
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
options.headers = headers
|
||||||
const proxyAddressString = subchannelAddressToString(address);
|
const proxyAddressString = subchannelAddressToString(address);
|
||||||
trace('Using proxy ' + proxyAddressString + ' to connect to ' + options.path);
|
trace('Using proxy ' + proxyAddressString + ' to connect to ' + options.path);
|
||||||
return new Promise<ProxyConnectionResult>((resolve, reject) => {
|
return new Promise<ProxyConnectionResult>((resolve, reject) => {
|
||||||
|
|
Loading…
Reference in New Issue