diff options
author | des <des@FreeBSD.org> | 2000-07-21 10:46:22 +0000 |
---|---|---|
committer | des <des@FreeBSD.org> | 2000-07-21 10:46:22 +0000 |
commit | c99122fbde8b09dc34a119469de4291488c6f82b (patch) | |
tree | a041ca0d3f216bfcefd37b7957dd9b94d3db4493 /lib/libfetch | |
parent | 2fa9607541dd09eaa3e0c0e2bf73b4b4e0cf403e (diff) | |
download | FreeBSD-src-c99122fbde8b09dc34a119469de4291488c6f82b.zip FreeBSD-src-c99122fbde8b09dc34a119469de4291488c6f82b.tar.gz |
The decision to use an HTTP proxy for FTP documents belongs in the FTP code
Diffstat (limited to 'lib/libfetch')
-rw-r--r-- | lib/libfetch/fetch.c | 12 | ||||
-rw-r--r-- | lib/libfetch/ftp.c | 25 |
2 files changed, 24 insertions, 13 deletions
diff --git a/lib/libfetch/fetch.c b/lib/libfetch/fetch.c index cb09efc..3eb8075 100644 --- a/lib/libfetch/fetch.c +++ b/lib/libfetch/fetch.c @@ -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); diff --git a/lib/libfetch/ftp.c b/lib/libfetch/ftp.c index de7d2d8..a5eb1d3 100644 --- a/lib/libfetch/ftp.c +++ b/lib/libfetch/ftp.c @@ -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 @@ -763,12 +763,26 @@ _ftp_cached_connect(struct url *url, char *flags) } /* + * 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 */ 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; } |