Date: Mon, 15 May 2000 04:31:58 +0900 (JST) From: Hajimu UMEMOTO (=?ISO-2022-JP?B?GyRCR19LXBsoQiA=?= =?ISO-2022-JP?B?GyRCSCUbKEI=?=) <ume@mahoroba.org> To: ben@scientia.demon.co.uk Cc: des@flood.ping.uio.no, arch@FreeBSD.org Subject: Re: fetch(1) Message-ID: <200005141931.e4EJVwF65961@peace.mahoroba.org> In-Reply-To: <20000514152427.Q10128@strontium.scientia.demon.co.uk> References: <xzpbt2djcj4.fsf@flood.ping.uio.no> <20000514152427.Q10128@strontium.scientia.demon.co.uk>
next in thread | previous in thread | raw e-mail | index | archive | help
----Next_Part(Mon_May_15_04:31:55_2000_601)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit >>>>> On Sun, 14 May 2000 15:24:27 +0100 >>>>> Ben Smithurst <ben@scientia.demon.co.uk> said: ben> Dag-Erling Smorgrav wrote: > I'm still waiting for comments about my libfetch-based fetch(1). Get > the latest tarball from <URL:http://www.freebsd.org/~des/software/>. > > (note that it needs -CURRENT's libfetch to work) ben> It seems that fetching an FTP url via an HTTP proxy server is now ben> broken. Setting HTTP_PROXY=www-cache:8080 used to work for FTP too, but ben> it doesn't anymore. How about this patch? If OK, I'll commit it. ----Next_Part(Mon_May_15_04:31:55_2000_601)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Description: libfetch-proxy.diff Content-Disposition: attachment; filename="libfetch-proxy.diff" Index: libfetch/fetch.c diff -u libfetch/fetch.c.orig libfetch/fetch.c --- libfetch/fetch.c.orig Fri May 12 01:35:25 2000 +++ libfetch/fetch.c Mon May 15 04:02:11 2000 @@ -69,13 +69,18 @@ FILE * fetchGet(struct url *URL, char *flags) { + int direct = (flags && strchr(flags, 'd')); + if (strcasecmp(URL->scheme, "file") == 0) return fetchGetFile(URL, flags); else if (strcasecmp(URL->scheme, "http") == 0) return fetchGetHTTP(URL, flags); - else if (strcasecmp(URL->scheme, "ftp") == 0) + else if (strcasecmp(URL->scheme, "ftp") == 0) { + if (!direct && + getenv("FTP_PROXY") == NULL && getenv("HTTP_PROXY") != NULL) + return fetchGetHTTP(URL, flags); return fetchGetFTP(URL, flags); - else { + } else { _url_seterr(URL_BAD_SCHEME); return NULL; } @@ -88,13 +93,18 @@ FILE * fetchPut(struct url *URL, char *flags) { + int direct = (flags && strchr(flags, 'd')); + if (strcasecmp(URL->scheme, "file") == 0) return fetchPutFile(URL, flags); else if (strcasecmp(URL->scheme, "http") == 0) return fetchPutHTTP(URL, flags); - else if (strcasecmp(URL->scheme, "ftp") == 0) + 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 { + } else { _url_seterr(URL_BAD_SCHEME); return NULL; } @@ -107,13 +117,18 @@ int fetchStat(struct url *URL, struct url_stat *us, char *flags) { + int direct = (flags && strchr(flags, 'd')); + if (strcasecmp(URL->scheme, "file") == 0) return fetchStatFile(URL, us, flags); else if (strcasecmp(URL->scheme, "http") == 0) return fetchStatHTTP(URL, us, flags); - else if (strcasecmp(URL->scheme, "ftp") == 0) + 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 { + } else { _url_seterr(URL_BAD_SCHEME); return -1; } @@ -126,13 +141,18 @@ struct url_ent * fetchList(struct url *URL, char *flags) { + int direct = (flags && strchr(flags, 'd')); + if (strcasecmp(URL->scheme, "file") == 0) return fetchListFile(URL, flags); else if (strcasecmp(URL->scheme, "http") == 0) return fetchListHTTP(URL, flags); - else if (strcasecmp(URL->scheme, "ftp") == 0) + 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 { + } else { _url_seterr(URL_BAD_SCHEME); return NULL; } Index: libfetch/http.c diff -u libfetch/http.c.orig libfetch/http.c --- libfetch/http.c.orig Fri May 12 01:35:27 2000 +++ libfetch/http.c Mon May 15 04:24:03 2000 @@ -311,10 +311,16 @@ if (!URL->port) { struct servent *se; - if ((se = getservbyname("http", "tcp")) != NULL) - URL->port = ntohs(se->s_port); + if (strcasecmp(URL->scheme, "ftp") == 0) + if ((se = getservbyname("ftp", "tcp")) != NULL) + URL->port = ntohs(se->s_port); + else + URL->port = 21; else - URL->port = 80; + if ((se = getservbyname("http", "tcp")) != NULL) + URL->port = ntohs(se->s_port); + else + URL->port = 80; } /* attempt to connect to proxy server */ @@ -363,6 +369,8 @@ /* if no proxy is configured or could be contacted, try direct */ if (sd == -1) { + if (strcasecmp(URL->scheme, "ftp") == 0) + goto ouch; if ((sd = _fetch_connect(URL->host, URL->port, verbose)) == -1) goto ouch; } @@ -394,8 +402,8 @@ /* send request (proxies require absolute form, so use that) */ if (verbose) - _fetch_info("requesting http://%s:%d%s", - URL->host, URL->port, URL->doc); + _fetch_info("requesting %s://%s:%d%s", + URL->scheme, URL->host, URL->port, URL->doc); _http_cmd(f, "%s %s://%s:%d%s HTTP/1.1" ENDL, op, URL->scheme, URL->host, URL->port, URL->doc); ----Next_Part(Mon_May_15_04:31:55_2000_601)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Description: My Signature Content-Disposition: attachment; filename=".signature-world" Hajimu UMEMOTO @ Internet Mutual Aid Society Yokohama, Japan ume@mahoroba.org ume@bisd.hitachi.co.jp ume@FreeBSD.org http://www.imasy.org/~ume/ ----Next_Part(Mon_May_15_04:31:55_2000_601)---- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200005141931.e4EJVwF65961>