Commit efdbfde7 authored by ERAMOTO Masaya's avatar ERAMOTO Masaya Committed by Daniel Stenberg
Browse files

url: Refactor detect_proxy()

If defined CURL_DISABLE_HTTP, detect_proxy() returned NULL. If not
defined CURL_DISABLE_HTTP, detect_proxy() checked noproxy list.

Thus refactor to set proxy to NULL instead of calling detect_proxy() if
define CURL_DISABLE_HTTP, and refactor to call detect_proxy() if not
define CURL_DISABLE_HTTP and the host is not in the noproxy list.
parent 1b575578
Loading
Loading
Loading
Loading
+40 −51
Original line number Diff line number Diff line
@@ -4853,7 +4853,6 @@ static char *detect_proxy(struct connectdata *conn)
{
  char *proxy = NULL;

#ifndef CURL_DISABLE_HTTP
  /* If proxy was not specified, we check for default proxy environment
   * variables, to enable i.e Lynx compliance:
   *
@@ -4871,15 +4870,7 @@ static char *detect_proxy(struct connectdata *conn)
   * For compatibility, the all-uppercase versions of these variables are
   * checked if the lowercase versions don't exist.
   */
  char *no_proxy=NULL;
  char proxy_env[128];

  no_proxy=curl_getenv("no_proxy");
  if(!no_proxy)
    no_proxy=curl_getenv("NO_PROXY");

  if(!check_noproxy(conn->host.name, no_proxy)) {
    /* It was not listed as without proxy */
  const char *protop = conn->handler->scheme;
  char *envp = proxy_env;
  char *prox;
@@ -4919,14 +4910,6 @@ static char *detect_proxy(struct connectdata *conn)
    if(!proxy)
      proxy=curl_getenv("ALL_PROXY");
  }
  } /* if(!check_noproxy(conn->host.name, no_proxy)) - it wasn't specified
       non-proxy */
  free(no_proxy);

#else /* !CURL_DISABLE_HTTP */

  (void)conn;
#endif /* CURL_DISABLE_HTTP */

  return proxy;
}
@@ -6267,7 +6250,13 @@ static CURLcode create_conn(struct Curl_easy *data,
    Curl_safefree(socksproxy);
  }
  else if(!proxy && !socksproxy)
#ifndef CURL_DISABLE_HTTP
    /* if the host is not in the noproxy list, detect proxy. */
    if(!check_noproxy(conn->host.name, no_proxy))
      proxy = detect_proxy(conn);
#else  /* !CURL_DISABLE_HTTP */
    proxy = NULL;
#endif /* CURL_DISABLE_HTTP */

  Curl_safefree(no_proxy);