libfetch: honor https_proxy variable for https

fixes #8160
cute-signatures
Timo Teräs 2018-01-03 10:43:31 +02:00
parent b0fcc56f22
commit 99e7bb93df
1 changed files with 30 additions and 11 deletions

View File

@ -764,25 +764,44 @@ ouch:
} }
static struct url * static struct url *
http_get_proxy(struct url * url, const char *flags) http_make_proxy_url(const char *env1, const char *env2)
{ {
struct url *purl; struct url *purl;
char *p; char *p;
if (flags != NULL && strchr(flags, 'd') != NULL) p = getenv(env1);
return (NULL); if (!p)
if (fetch_no_proxy_match(url->host)) p = getenv(env2);
return (NULL); if (!p || !*p)
if (((p = getenv("HTTP_PROXY")) || (p = getenv("http_proxy"))) && return NULL;
*p && (purl = fetchParseURL(p))) {
purl = fetchParseURL(p);
if (!purl)
return NULL;
if (!*purl->scheme) if (!*purl->scheme)
strcpy(purl->scheme, SCHEME_HTTP); strcpy(purl->scheme, SCHEME_HTTP);
if (!purl->port) if (!purl->port)
purl->port = fetch_default_proxy_port(purl->scheme); purl->port = fetch_default_proxy_port(purl->scheme);
if (strcasecmp(purl->scheme, SCHEME_HTTP) == 0) if (strcasecmp(purl->scheme, SCHEME_HTTP) == 0)
return (purl); return purl;
fetchFreeURL(purl); fetchFreeURL(purl);
return NULL;
} }
static struct url *
http_get_proxy(struct url * url, const char *flags)
{
if (flags != NULL && strchr(flags, 'd') != NULL)
return (NULL);
if (fetch_no_proxy_match(url->host))
return (NULL);
if (strcasecmp(url->scheme, SCHEME_HTTPS) == 0)
return http_make_proxy_url("HTTPS_PROXY", "https_proxy");
if (strcasecmp(url->scheme, SCHEME_HTTP) == 0)
return http_make_proxy_url("HTTP_PROXY", "http_proxy");
return (NULL); return (NULL);
} }