From owner-freebsd-arch Sun May 14 12:36:45 2000 Delivered-To: freebsd-arch@freebsd.org Received: from peace.mahoroba.org (peace.calm.imasy.or.jp [202.227.26.34]) by hub.freebsd.org (Postfix) with ESMTP id 68C3637B5FA for ; Sun, 14 May 2000 12:36:37 -0700 (PDT) (envelope-from ume@mahoroba.org) Received: from localhost (IDENT:HiQ5BEdt1BkHxWAK6c4IIJWZjo+1cGTWSZ++Saj6taXPJzoUo5OzOdpw9NpqVldy@localhost [::1]) by peace.mahoroba.org (8.10.1/3.7W-peace) with ESMTP id e4EJVwF65961; Mon, 15 May 2000 04:31:58 +0900 (JST) (envelope-from ume@mahoroba.org) Date: Mon, 15 May 2000 04:31:58 +0900 (JST) Message-Id: <200005141931.e4EJVwF65961@peace.mahoroba.org> To: ben@scientia.demon.co.uk Cc: des@flood.ping.uio.no, arch@FreeBSD.org Subject: Re: fetch(1) In-Reply-To: <20000514152427.Q10128@strontium.scientia.demon.co.uk> References: <20000514152427.Q10128@strontium.scientia.demon.co.uk> X-Mailer: xcite1.20> Mew version 1.94.2 on Emacs 20.6 / Mule 4.0 =?iso-2022-jp?B?KBskQjJWMWMbKEIp?= X-PGP-Public-Key: http://www.imasy.org/~ume/publickey.asc X-PGP-Fingerprint: 6B 0C 53 FC 5D D0 37 91 05 D0 B3 EF 36 9B 6A BC X-URL: http://www.imasy.org/~ume/ X-OS: FreeBSD 5.0-CURRENT Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="--Next_Part(Mon_May_15_04:31:55_2000_601)--" Content-Transfer-Encoding: 7bit From: Hajimu UMEMOTO (=?ISO-2022-JP?B?GyRCR19LXBsoQiA=?= =?ISO-2022-JP?B?GyRCSCUbKEI=?=) X-Dispatcher: imput version 20000228(IM140) Lines: 171 Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG ----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 said: ben> Dag-Erling Smorgrav wrote: > I'm still waiting for comments about my libfetch-based fetch(1). Get > the latest tarball from . > > (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