From 22e21f9da4fa01feaa93de99ce7b893f3eef60f9 Mon Sep 17 00:00:00 2001 From: ikedam Date: Sat, 11 Jan 2020 12:39:29 +0900 Subject: [PATCH] Treat an empty `http_proxy` mean "Don't use proxy" and skip parsing it --- src/core/ext/filters/client_channel/http_proxy.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/core/ext/filters/client_channel/http_proxy.cc b/src/core/ext/filters/client_channel/http_proxy.cc index fdaf58ff804..efd188c165e 100644 --- a/src/core/ext/filters/client_channel/http_proxy.cc +++ b/src/core/ext/filters/client_channel/http_proxy.cc @@ -47,6 +47,7 @@ namespace { */ char* GetHttpProxyServer(char** user_cred) { GPR_ASSERT(user_cred != nullptr); + grpc_uri* uri = nullptr; char* proxy_name = nullptr; char** authority_strs = nullptr; 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("http_proxy"); 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) { gpr_log(GPR_ERROR, "cannot parse value of 'http_proxy' env var"); goto done;