mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-12-02 04:13:39 +00:00
The decision to use an HTTP proxy for FTP documents belongs in the FTP code
This commit is contained in:
parent
2e88106bd1
commit
dfe7c55fcc
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=63713
@ -80,9 +80,6 @@ fetchXGet(struct url *URL, struct url_stat *us, char *flags)
|
||||
else if (strcasecmp(URL->scheme, "http") == 0)
|
||||
return fetchXGetHTTP(URL, us, flags);
|
||||
else if (strcasecmp(URL->scheme, "ftp") == 0) {
|
||||
if (!direct &&
|
||||
getenv("FTP_PROXY") == NULL && getenv("HTTP_PROXY") != NULL)
|
||||
return fetchXGetHTTP(URL, us, flags);
|
||||
return fetchXGetFTP(URL, us, flags);
|
||||
} else {
|
||||
_url_seterr(URL_BAD_SCHEME);
|
||||
@ -115,9 +112,6 @@ fetchPut(struct url *URL, char *flags)
|
||||
else if (strcasecmp(URL->scheme, "http") == 0)
|
||||
return fetchPutHTTP(URL, flags);
|
||||
else if (strcasecmp(URL->scheme, "ftp") == 0) {
|
||||
if (!direct &&
|
||||
getenv("FTP_PROXY") == NULL && getenv("HTTP_PROXY") != NULL)
|
||||
return fetchPutHTTP(URL, flags);
|
||||
return fetchPutFTP(URL, flags);
|
||||
} else {
|
||||
_url_seterr(URL_BAD_SCHEME);
|
||||
@ -140,9 +134,6 @@ fetchStat(struct url *URL, struct url_stat *us, char *flags)
|
||||
else if (strcasecmp(URL->scheme, "http") == 0)
|
||||
return fetchStatHTTP(URL, us, flags);
|
||||
else if (strcasecmp(URL->scheme, "ftp") == 0) {
|
||||
if (!direct &&
|
||||
getenv("FTP_PROXY") == NULL && getenv("HTTP_PROXY") != NULL)
|
||||
return fetchStatHTTP(URL, us, flags);
|
||||
return fetchStatFTP(URL, us, flags);
|
||||
} else {
|
||||
_url_seterr(URL_BAD_SCHEME);
|
||||
@ -165,9 +156,6 @@ fetchList(struct url *URL, char *flags)
|
||||
else if (strcasecmp(URL->scheme, "http") == 0)
|
||||
return fetchListHTTP(URL, flags);
|
||||
else if (strcasecmp(URL->scheme, "ftp") == 0) {
|
||||
if (!direct &&
|
||||
getenv("FTP_PROXY") == NULL && getenv("HTTP_PROXY") != NULL)
|
||||
return fetchListHTTP(URL, flags);
|
||||
return fetchListFTP(URL, flags);
|
||||
} else {
|
||||
_url_seterr(URL_BAD_SCHEME);
|
||||
|
@ -594,7 +594,7 @@ _ftp_connect(char *host, int port, char *user, char *pwd, char *flags)
|
||||
af = AF_INET6;
|
||||
|
||||
/* check for proxy */
|
||||
if (!direct && (p = getenv("FTP_PROXY")) != NULL) {
|
||||
if (!direct && (p = getenv("FTP_PROXY")) != NULL && *p) {
|
||||
char c = 0;
|
||||
|
||||
#ifdef INET6
|
||||
@ -762,6 +762,17 @@ _ftp_cached_connect(struct url *url, char *flags)
|
||||
return cd;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check to see if we should use an HTTP proxy instead
|
||||
*/
|
||||
static int
|
||||
_ftp_use_http_proxy(void)
|
||||
{
|
||||
char *p;
|
||||
|
||||
return ((p = getenv("HTTP_PROXY")) && *p && !getenv("FTP_PROXY"));
|
||||
}
|
||||
|
||||
/*
|
||||
* Get and stat file
|
||||
*/
|
||||
@ -769,6 +780,9 @@ FILE *
|
||||
fetchXGetFTP(struct url *url, struct url_stat *us, char *flags)
|
||||
{
|
||||
int cd;
|
||||
|
||||
if (_ftp_use_http_proxy())
|
||||
return fetchXGetHTTP(url, us, flags);
|
||||
|
||||
/* connect to server */
|
||||
if ((cd = _ftp_cached_connect(url, flags)) == NULL)
|
||||
@ -804,6 +818,9 @@ fetchPutFTP(struct url *url, char *flags)
|
||||
{
|
||||
int cd;
|
||||
|
||||
if (_ftp_use_http_proxy())
|
||||
return fetchPutHTTP(url, flags);
|
||||
|
||||
/* connect to server */
|
||||
if ((cd = _ftp_cached_connect(url, flags)) == NULL)
|
||||
return NULL;
|
||||
@ -825,6 +842,9 @@ fetchStatFTP(struct url *url, struct url_stat *us, char *flags)
|
||||
{
|
||||
int cd;
|
||||
|
||||
if (_ftp_use_http_proxy())
|
||||
return fetchStatHTTP(url, us, flags);
|
||||
|
||||
us->size = -1;
|
||||
us->atime = us->mtime = 0;
|
||||
|
||||
@ -847,6 +867,9 @@ extern void warnx(char *, ...);
|
||||
struct url_ent *
|
||||
fetchListFTP(struct url *url, char *flags)
|
||||
{
|
||||
if (_ftp_use_http_proxy())
|
||||
return fetchListHTTP(url, flags);
|
||||
|
||||
warnx("fetchListFTP(): not implemented");
|
||||
return NULL;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user