Fix review comments:

- Clarify comments
- Simplify code by using grpc_channel_args_find_string function
pull/20866/head
Kevin Freeman 5 years ago
parent 561281f268
commit 743824be5c
  1. 2
      include/grpc/impl/codegen/grpc_types.h
  2. 14
      src/core/ext/filters/client_channel/http_proxy.cc

@ -374,7 +374,7 @@ typedef struct {
/** If set to zero, disables use of http proxies. Enabled by default. */
#define GRPC_ARG_ENABLE_HTTP_PROXY "grpc.enable_http_proxy"
/** Channel arg to set http proxy per channel. If set, the channel arg
* value will be prefered over the http_proxy envrionment settings. */
* value will be prefered over the envrionment variable settings. */
#define GRPC_ARG_HTTP_PROXY "grpc.http_proxy"
/** If set to non zero, surfaces the user agent string to the server. User
agent is surfaced by default. */

@ -47,13 +47,15 @@ static char* get_http_proxy_server(const grpc_channel_args* args, char** user_cr
char* proxy_name = nullptr;
char** authority_strs = nullptr;
size_t authority_nstrs;
/* Check channel arguments in case a per channel proxy is set. Otherwise,
* prefer using 'grpc_proxy'. Fallback on 'http_proxy' if it is not set.
* Also prefer using 'https_proxy' with fallback on 'http_proxy'. The
* fallback behavior can be removed if there's a demand for it.
/* We check the following places to determine the HTTP proxy to use, stopping
* at the first one that is set:
* 1. GRPC_ARG_HTTP_PROXY channel arg
* 2. grpc_proxy environment variable
* 3. https_proxy environment variable
* 4. http_proxy environment variable
* If none of the above are set, then no HTTP proxy will be used.
*/
const grpc_arg* arg = grpc_channel_args_find(args, GRPC_ARG_HTTP_PROXY);
char* uri_str = gpr_strdup(grpc_channel_arg_get_string(arg));
char* uri_str = gpr_strdup(grpc_channel_args_find_string(args, GRPC_ARG_HTTP_PROXY));
if (uri_str == nullptr) uri_str = gpr_getenv("grpc_proxy");
if (uri_str == nullptr) uri_str = gpr_getenv("https_proxy");
if (uri_str == nullptr) uri_str = gpr_getenv("http_proxy");

Loading…
Cancel
Save