summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorGarrett Wollman <wollman@FreeBSD.org>1999-02-25 18:36:32 +0000
committerGarrett Wollman <wollman@FreeBSD.org>1999-02-25 18:36:32 +0000
commit4fea87acee3f69f5760e61235189ce154ceba1eb (patch)
tree33625d233e46f1ed986126d0cac6ebad6908fc8b /usr.bin
parentfce81da2c38c83f21b8f36937e7636060ca36358 (diff)
Notes
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/fetch/fetch.141
-rw-r--r--usr.bin/fetch/ftp.c7
-rw-r--r--usr.bin/fetch/http.c25
-rw-r--r--usr.bin/fetch/main.c16
4 files changed, 69 insertions, 20 deletions
diff --git a/usr.bin/fetch/fetch.1 b/usr.bin/fetch/fetch.1
index f3be659841fa..080c7d6d852c 100644
--- a/usr.bin/fetch/fetch.1
+++ b/usr.bin/fetch/fetch.1
@@ -1,5 +1,5 @@
-.\" $Id: fetch.1,v 1.26 1998/12/08 13:00:48 cracauer Exp $
-.Dd January 15, 1999
+.\" $Id: fetch.1,v 1.29 1999/02/23 18:51:13 wollman Exp $
+.Dd February 22, 1999
.Dt FETCH 1
.Os FreeBSD 3.1
.Sh NAME
@@ -7,7 +7,7 @@
.Nd retrieve a file by Uniform Resource Locator
.Sh SYNOPSIS
.Nm fetch
-.Op Fl MPablmnpqrtv
+.Op Fl AMPablmnpqrtv
.Op Fl S Ar size
.Op Fl T Ar timeout
.Op Fl o Ar file
@@ -49,6 +49,10 @@ flags.
.Pp
The following options are available:
.Bl -tag -width Fl
+.It Fl A
+Do not automatically follow ``temporary'' (302) redirects. Some
+broken Web sites will return a redirect instead of a not-found error
+when the requested object does not exist.
.It Fl a
Automatically retry the transfer upon soft failures.
.It Fl b
@@ -151,6 +155,12 @@ URL's, a username and password may be specified, using the syntax
If the path is to be absolute, as opposed to relative to the user's
home directory, it must start with %2F, as in
.Li ftp://root:mypass@localhost/%2Fetc/passwd .
+.Nm Fetch
+condenses multiple slashes in an
+.Tn ftp
+URL into a single slash; literal multiple slashes translate to an
+.Tn ftp
+protocol error.
.Sh PROXY SERVERS
Many sites use application gateways (``proxy servers'') in their
firewalls in order to allow communication across the firewall using a
@@ -186,7 +196,7 @@ proxy client passes the remote username, host and port as the
.Tn FTP
session's username, in the form
.Do Va remoteuser Ns Li \&@ Ns Va remotehost
-.Op Li \^@ Ns Va port
+.Op Li \&@ Ns Va port
.Dc .
The
.Tn HTTP
@@ -248,7 +258,7 @@ or
.Pp
and
.Nm
-will prompt for the missing information if it is required. She might
+will prompt for any missing information when it is required. She might
also specify a realm of
.Dq Li \&*
instead of
@@ -326,6 +336,27 @@ connection.
.%O RFC 2068
.%D January 1997
.Re
+.Rs
+.%A T. Berners-Lee
+.%A L. Masinter
+.%A M. McCahill
+.%T "Uniform Resource Locators (URL)"
+.%O RFC 1738
+.%D December 1994
+.Re
+.Rs
+.%A J. Postel
+.%A J.K. Reynolds
+.%T "File Transfer Protocol"
+.%O RFC 959 / STD 9
+.%D October 1985
+.Re
+.Rs
+.%A M.R. Horton
+.%T "Standard for interchange of USENET messages."
+.%O RFC 850
+.%D June 1983
+.Re
.Sh HISTORY
The
.Nm fetch
diff --git a/usr.bin/fetch/ftp.c b/usr.bin/fetch/ftp.c
index 45c8ecfc508a..30b8f4539af5 100644
--- a/usr.bin/fetch/ftp.c
+++ b/usr.bin/fetch/ftp.c
@@ -26,7 +26,7 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: ftp.c,v 1.10 1998/09/20 00:01:26 jkh Exp $
+ * $Id: ftp.c,v 1.13 1999/02/05 01:01:17 fenner Exp $
*/
#include <sys/types.h>
@@ -180,9 +180,10 @@ ftp_parse(struct fetch_state *fs, const char *uri)
* we just pretend that multiple slashes are a
* single slash.
*/
- if (*r == '\0')
+ if (*r == '\0') {
+ warnx("skipping double slash in FTP URL; see man page or RFC1738.");
ftps->ftp_remote_ndirs--;
- else
+ } else
*dp++ = percent_decode(r);
r = s;
}
diff --git a/usr.bin/fetch/http.c b/usr.bin/fetch/http.c
index 2f08c1d2be0f..21d6c2ec0e8d 100644
--- a/usr.bin/fetch/http.c
+++ b/usr.bin/fetch/http.c
@@ -26,7 +26,7 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: http.c,v 1.23 1999/01/15 16:56:22 wollman Exp $
+ * $Id: http.c,v 1.26 1999/02/23 18:51:13 wollman Exp $
*/
#include <sys/types.h>
@@ -165,7 +165,7 @@ http_parse(struct fetch_state *fs, const char *u)
strncat(hostname, p, q - p);
p = slash;
- if (colon && colon + 1 != slash) {
+ if (q == colon && colon + 1 != slash) {
unsigned long ul;
char *ep;
@@ -703,7 +703,6 @@ got100reply:
line[linelen - 1] = '\0'; /* turn line into a string */
status = http_first_line(line);
- /* In the future, we might handle redirection and other responses. */
switch(status) {
case 100: /* Continue */
goto got100reply;
@@ -715,17 +714,29 @@ got100reply:
/* can only happen when restarting */
break;
case 301: /* Resource has moved permanently */
- if (!fs->fs_auto_retry)
+ if (fs->fs_auto_retry < 1)
errstr = safe_strdup(line);
else
redirection = 301;
break;
case 302: /* Resource has moved temporarily */
/*
- * We don't test fs->fs_auto_retry here so that this
- * sort of redirection is transparent to the user.
+ * We formerly didn't test fs->fs_auto_retry here,
+ * so that this sort of redirection would be transparent
+ * to the user. Unfortunately, there are a lot of idiots
+ * out there running Web sites, and some of them have
+ * decided to implement the following stupidity: rather
+ * than returning the correct `404 Not Found' error
+ * when something is not found, they instead return
+ * a 302 redirect, giving the erroneous impression that
+ * the requested resource actually exists. This
+ * breaks any client which expects a non-existent resource
+ * to elicit a 40x response. Grrr.
*/
- redirection = 302;
+ if (fs->fs_auto_retry < 0) /* -A flag */
+ errstr = safe_strdup(line);
+ else
+ redirection = 302;
break;
case 304: /* Object is unmodified */
if (fs->fs_mirror) {
diff --git a/usr.bin/fetch/main.c b/usr.bin/fetch/main.c
index 8b24dad4f5c1..ee0a3208d7a3 100644
--- a/usr.bin/fetch/main.c
+++ b/usr.bin/fetch/main.c
@@ -24,7 +24,7 @@
* SUCH DAMAGE.
*/
-/* $Id: main.c,v 1.48 1998/11/08 23:18:48 des Exp $ */
+/* $Id: main.c,v 1.50 1999/02/23 18:51:13 wollman Exp $ */
#include <sys/types.h>
@@ -49,10 +49,11 @@ static sigjmp_buf sigbuf;
static int get(struct fetch_state *volatile fs);
static void
-usage()
+usage(void)
{
- fprintf(stderr, "%s\n%s\n",
- "usage: fetch [-DHILMNPRTVablmnpqrstv] [-o outputfile] [-S bytes]",
+ fprintf(stderr,
+ "usage: fetch [-ADHILMNPRTVablmnpqrstv] [-o outputfile] "
+ "[-S bytes]\n"
" [-f file -h host [-c dir] | URL]");
exit(EX_USAGE);
}
@@ -75,8 +76,13 @@ main(int argc, char *const *argv)
fs.fs_expectedsize = -1;
change_to_dir = file_to_get = hostname = 0;
- while ((c = getopt(argc, argv, "abc:D:f:h:HIlLmMnNo:pPqRrS:stT:vV:")) != -1) {
+#define OPT_STRING "Aabc:D:f:h:HIlLmMnNo:pPqRrS:stT:vV:"
+ while ((c = getopt(argc, argv, OPT_STRING)) != -1) {
switch (c) {
+ case 'A':
+ fs.fs_auto_retry = -1;
+ break;
+
case 'D': case 'H': case 'I': case 'L': case 'N': case 'V':
break; /* ncftp compatibility */