mirror of
https://github.com/grpc/grpc-node.git
synced 2025-12-08 18:23:54 +00:00
feat: support "http_proxy" channel option
This commit is contained in:
parent
dac1da47a8
commit
276321de66
@ -36,6 +36,7 @@ export interface ChannelOptions {
|
||||
'grpc.max_send_message_length'?: number;
|
||||
'grpc.max_receive_message_length'?: number;
|
||||
'grpc.enable_http_proxy'?: number;
|
||||
'grpc.http_proxy'?: string;
|
||||
/* http_connect_target and http_connect_creds are used for passing data
|
||||
* around internally, and should not be documented as public-facing options
|
||||
*/
|
||||
|
||||
@ -41,7 +41,7 @@ interface ProxyInfo {
|
||||
creds?: string;
|
||||
}
|
||||
|
||||
function getProxyInfo(): ProxyInfo {
|
||||
function getProxyInfo(proxy?: string): ProxyInfo {
|
||||
let proxyEnv = '';
|
||||
let envVar = '';
|
||||
/* Prefer using 'grpc_proxy'. Fallback on 'http_proxy' if it is not set.
|
||||
@ -57,6 +57,9 @@ function getProxyInfo(): ProxyInfo {
|
||||
} else if (process.env.http_proxy) {
|
||||
envVar = 'http_proxy';
|
||||
proxyEnv = process.env.http_proxy;
|
||||
} else if(proxy) {
|
||||
envVar = 'proxy';
|
||||
proxyEnv = proxy
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
@ -190,7 +193,7 @@ export function mapProxyName(
|
||||
if (target.scheme === 'unix') {
|
||||
return noProxyResult;
|
||||
}
|
||||
const proxyInfo = getProxyInfo();
|
||||
const proxyInfo = getProxyInfo(options['grpc.http_proxy']);
|
||||
if (!proxyInfo.address) {
|
||||
return noProxyResult;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user