diff options
Diffstat (limited to 'lib/libfetch/ftp.c')
-rw-r--r-- | lib/libfetch/ftp.c | 25 |
1 files changed, 24 insertions, 1 deletions
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; } |