Merge pull request #21632 from ikedam/feature/no_proxy_for_empty_value

Treat an empty `http_proxy` mean "Don't use proxy" and skip parsing it
pull/21703/head
Yash Tibrewal 5 years ago committed by GitHub
commit 4466a4ce61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      src/core/ext/filters/client_channel/http_proxy.cc

@ -47,6 +47,7 @@ namespace {
*/ */
char* GetHttpProxyServer(char** user_cred) { char* GetHttpProxyServer(char** user_cred) {
GPR_ASSERT(user_cred != nullptr); GPR_ASSERT(user_cred != nullptr);
grpc_uri* uri = nullptr;
char* proxy_name = nullptr; char* proxy_name = nullptr;
char** authority_strs = nullptr; char** authority_strs = nullptr;
size_t authority_nstrs; size_t authority_nstrs;
@ -58,7 +59,9 @@ char* GetHttpProxyServer(char** user_cred) {
if (uri_str == nullptr) uri_str = gpr_getenv("https_proxy"); if (uri_str == nullptr) uri_str = gpr_getenv("https_proxy");
if (uri_str == nullptr) uri_str = gpr_getenv("http_proxy"); if (uri_str == nullptr) uri_str = gpr_getenv("http_proxy");
if (uri_str == nullptr) return nullptr; if (uri_str == nullptr) return nullptr;
grpc_uri* uri = grpc_uri_parse(uri_str, false /* suppress_errors */); // an emtpy value means "don't use proxy"
if (uri_str[0] == '\0') goto done;
uri = grpc_uri_parse(uri_str, false /* suppress_errors */);
if (uri == nullptr || uri->authority == nullptr) { if (uri == nullptr || uri->authority == nullptr) {
gpr_log(GPR_ERROR, "cannot parse value of 'http_proxy' env var"); gpr_log(GPR_ERROR, "cannot parse value of 'http_proxy' env var");
goto done; goto done;

Loading…
Cancel
Save