diff --git a/lib/libfetch/ftp.c b/lib/libfetch/ftp.c index 56d0bf572ce3..b2550b11289a 100644 --- a/lib/libfetch/ftp.c +++ b/lib/libfetch/ftp.c @@ -889,11 +889,13 @@ _ftp_cached_connect(struct url *url, struct url *purl, const char *flags) * Check the proxy settings */ static struct url * -_ftp_get_proxy(void) +_ftp_get_proxy(const char *flags) { struct url *purl; char *p; + if (strchr(flags, 'd') != NULL) + return (NULL); if (((p = getenv("FTP_PROXY")) || (p = getenv("ftp_proxy")) || (p = getenv("HTTP_PROXY")) || (p = getenv("http_proxy"))) && *p && (purl = fetchParseURL(p)) != NULL) { @@ -970,7 +972,7 @@ _ftp_request(struct url *url, const char *op, struct url_stat *us, FILE * fetchXGetFTP(struct url *url, struct url_stat *us, const char *flags) { - return (_ftp_request(url, "RETR", us, _ftp_get_proxy(), flags)); + return (_ftp_request(url, "RETR", us, _ftp_get_proxy(flags), flags)); } /* @@ -989,8 +991,8 @@ FILE * fetchPutFTP(struct url *url, const char *flags) { - return _ftp_request(url, CHECK_FLAG('a') ? "APPE" : "STOR", NULL, - _ftp_get_proxy(), flags); + return (_ftp_request(url, CHECK_FLAG('a') ? "APPE" : "STOR", NULL, + _ftp_get_proxy(flags), flags)); } /* @@ -999,9 +1001,12 @@ fetchPutFTP(struct url *url, const char *flags) int fetchStatFTP(struct url *url, struct url_stat *us, const char *flags) { + FILE *f; - if (_ftp_request(url, "STAT", us, _ftp_get_proxy(), flags) == NULL) + f = _ftp_request(url, "STAT", us, _ftp_get_proxy(flags), flags); + if (f == NULL) return (-1); + fclose(f); return (0); } diff --git a/lib/libfetch/http.c b/lib/libfetch/http.c index 5f44c5358359..1fc4cd5932c0 100644 --- a/lib/libfetch/http.c +++ b/lib/libfetch/http.c @@ -696,11 +696,13 @@ _http_connect(struct url *URL, struct url *purl, const char *flags) } static struct url * -_http_get_proxy(void) +_http_get_proxy(const char *flags) { struct url *purl; char *p; + if (strchr(flags, 'd') != NULL) + return (NULL); if (((p = getenv("HTTP_PROXY")) || (p = getenv("http_proxy"))) && (purl = fetchParseURL(p))) { if (!*purl->scheme) @@ -1108,7 +1110,7 @@ _http_request(struct url *URL, const char *op, struct url_stat *us, FILE * fetchXGetHTTP(struct url *URL, struct url_stat *us, const char *flags) { - return (_http_request(URL, "GET", us, _http_get_proxy(), flags)); + return (_http_request(URL, "GET", us, _http_get_proxy(flags), flags)); } /* @@ -1138,7 +1140,8 @@ fetchStatHTTP(struct url *URL, struct url_stat *us, const char *flags) { FILE *f; - if ((f = _http_request(URL, "HEAD", us, _http_get_proxy(), flags)) == NULL) + f = _http_request(URL, "HEAD", us, _http_get_proxy(flags), flags); + if (f == NULL) return (-1); fclose(f); return (0);