diff options
author | Timo Teräs <timo.teras@iki.fi> | 2018-01-03 10:43:31 +0200 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2018-01-09 09:55:26 +0200 |
commit | c051f6f10ff08fd68a091cd236c3606027952db3 (patch) | |
tree | b2320a24058ac4b366c8bdb0e912c69d9be6de55 | |
parent | 6ee77576e7c16c23784c69f82d90be98deb07515 (diff) | |
download | apk-tools-c051f6f10ff08fd68a091cd236c3606027952db3.tar.gz apk-tools-c051f6f10ff08fd68a091cd236c3606027952db3.tar.bz2 apk-tools-c051f6f10ff08fd68a091cd236c3606027952db3.tar.xz apk-tools-c051f6f10ff08fd68a091cd236c3606027952db3.zip |
libfetch: honor https_proxy variable for https
fixes #8160
(cherry picked from commit 99e7bb93dfff2f43987b81ce7600ad8fbd0ce64c)
-rw-r--r-- | libfetch/http.c | 41 |
1 files changed, 30 insertions, 11 deletions
diff --git a/libfetch/http.c b/libfetch/http.c index 7b33e3c..d66fcc6 100644 --- a/libfetch/http.c +++ b/libfetch/http.c @@ -764,25 +764,44 @@ ouch: } 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; char *p; + p = getenv(env1); + if (!p) + p = getenv(env2); + if (!p || !*p) + return NULL; + + purl = fetchParseURL(p); + if (!purl) + return NULL; + + if (!*purl->scheme) + strcpy(purl->scheme, SCHEME_HTTP); + if (!purl->port) + purl->port = fetch_default_proxy_port(purl->scheme); + + if (strcasecmp(purl->scheme, SCHEME_HTTP) == 0) + return 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 (((p = getenv("HTTP_PROXY")) || (p = getenv("http_proxy"))) && - *p && (purl = fetchParseURL(p))) { - if (!*purl->scheme) - strcpy(purl->scheme, SCHEME_HTTP); - if (!purl->port) - purl->port = fetch_default_proxy_port(purl->scheme); - if (strcasecmp(purl->scheme, SCHEME_HTTP) == 0) - return (purl); - fetchFreeURL(purl); - } + 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); } |