Don't parse the proxy URL unless we're actually going to use it. No real

functional difference, but debugging output will be less confusing.
This commit is contained in:
des 2003-03-11 08:20:58 +00:00
parent 1e928d5480
commit 2d46bf6bbe
2 changed files with 16 additions and 8 deletions

View File

@ -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);
}

View File

@ -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);