summaryrefslogtreecommitdiff
path: root/usr.bin/fetch
diff options
context:
space:
mode:
authorcvs2svn <cvs2svn@FreeBSD.org>1999-01-21 00:55:32 +0000
committercvs2svn <cvs2svn@FreeBSD.org>1999-01-21 00:55:32 +0000
commit76b5366091f76c9bc73570149ef5055648fc2c39 (patch)
tree590d020e0f2a5bea6e09d66d951a674443b21d67 /usr.bin/fetch
parent4b4d01da6f07f7754ff6a6e4f5223e9f0984d1a6 (diff)
Diffstat (limited to 'usr.bin/fetch')
-rw-r--r--usr.bin/fetch/fetch.152
-rw-r--r--usr.bin/fetch/fetch.h3
-rw-r--r--usr.bin/fetch/ftp.c16
-rw-r--r--usr.bin/fetch/http.c70
-rw-r--r--usr.bin/fetch/main.c13
5 files changed, 19 insertions, 135 deletions
diff --git a/usr.bin/fetch/fetch.1 b/usr.bin/fetch/fetch.1
index f3be659841fa9..20be53dd2f696 100644
--- a/usr.bin/fetch/fetch.1
+++ b/usr.bin/fetch/fetch.1
@@ -1,20 +1,19 @@
-.\" $Id: fetch.1,v 1.26 1998/12/08 13:00:48 cracauer Exp $
-.Dd January 15, 1999
+.\" $Id: fetch.1,v 1.23 1998/05/09 21:39:49 wollman Exp $
+.Dd July 2, 1996
.Dt FETCH 1
-.Os FreeBSD 3.1
+.Os FreeBSD 2.2
.Sh NAME
.Nm fetch
.Nd retrieve a file by Uniform Resource Locator
.Sh SYNOPSIS
.Nm fetch
-.Op Fl MPablmnpqrtv
+.Op Fl MPabmnpqr
.Op Fl S Ar size
-.Op Fl T Ar timeout
.Op Fl o Ar file
.Ar URL
.Op Ar ...
.Nm fetch
-.Op Fl MPRlmnpqrv
+.Op Fl MPRmnpqr
.Op Fl S Ar size
.Op Fl o Ar file
.Op Fl c Ar dir
@@ -103,7 +102,7 @@ under any circumstances, even if the transfer failed or was incomplete.
.It Fl r
Restart a previously interrupted transfer.
.It Fl S Ar bytes
-Require the file size reported by
+Require file size reported by
.Tn FTP
or
.Tn HTTP
@@ -115,9 +114,10 @@ This option is useful to prevent
.Nm fetch
from downloading a file that is either incomplete or the wrong version,
given the correct size of the file in advance.
-.It Fl s
-Ask server for size of file in bytes and print it to stdout. Do not
-actually fetch the file.
+.It Fl t
+Work around a different set of buggy
+.Tn TCP
+implementations.
.It Fl T Ar seconds
Set timeout value to
.Ar seconds.
@@ -126,10 +126,6 @@ Overrides the environment variables
for ftp transfers or
.Ev HTTP_TIMEOUT
for http transfers if set.
-.It Fl t
-Work around a different set of buggy
-.Tn TCP
-implementations.
.It Fl v
Increase verbosity. More
.Fl v Ns \&'s
@@ -316,16 +312,6 @@ connection.
.Sh SEE ALSO
.Xr ftp 1 ,
.Xr tftp 1
-.Rs
-.%A R. Fielding
-.%A J. Gettys
-.%A J. Mogul
-.%A H. Frystyk
-.%A T. Berners-Lee
-.%T "Hypertext Transfer Protocol \-\- HTTP/1.1"
-.%O RFC 2068
-.%D January 1997
-.Re
.Sh HISTORY
The
.Nm fetch
@@ -381,21 +367,3 @@ and
.Fl b
involves a minimum of two round trips (for small replies), one less than
other implementations.
-.Pp
-The
-.Tn HTTP
-standard requires interpretation of the
-.Tn RFC 850
-date format, which does not provide a century indication. Versions of
-.Nm fetch
-prior to
-.Fx 3.1
-would interpret all such dates as being in the 1900s. This version of
-.Nm fetch
-interprets such dates according to the rule given in
-.Tn RFC 2068 :
-.Bd -literal -offset indent
- o HTTP/1.1 clients and caches should assume that an RFC-850 date
- which appears to be more than 50 years in the future is in fact
- in the past (this helps solve the "year 2000" problem).
-.Ed
diff --git a/usr.bin/fetch/fetch.h b/usr.bin/fetch/fetch.h
index 685fdd6730426..aac3fbcb34f7e 100644
--- a/usr.bin/fetch/fetch.h
+++ b/usr.bin/fetch/fetch.h
@@ -26,7 +26,7 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: fetch.h,v 1.6 1998/09/20 00:01:26 jkh Exp $
+ * $Id: fetch.h,v 1.5 1997/08/05 20:18:38 ache Exp $
*/
#ifndef fetch_h
@@ -52,7 +52,6 @@ struct fetch_state {
int fs_linux_bug; /* -b option */
int fs_use_connect; /* -t option */
off_t fs_expectedsize; /* -S option */
- int fs_reportsize; /* -s option */
time_t fs_modtime;
void *fs_proto;
int (*fs_retrieve)(struct fetch_state *);
diff --git a/usr.bin/fetch/ftp.c b/usr.bin/fetch/ftp.c
index 45c8ecfc508a0..6c6c71c10b747 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.9 1997/10/08 18:43:53 fenner Exp $
*/
#include <sys/types.h>
@@ -375,20 +375,6 @@ ftp_retrieve(struct fetch_state *fs)
}
}
size = ftpGetSize(ftp, ftps->ftp_remote_file);
-
- if (fs->fs_reportsize) {
- fclose(ftp);
- if (size == -1) {
- warnx("%s: size not known\n", fs->fs_outputfile);
- printf("Unknown\n");
- return 1;
- }
- else {
- printf("%qd\n", (quad_t)size);
- return 0;
- }
- }
-
if (size > 0 && fs->fs_expectedsize != -1 && size != fs->fs_expectedsize) {
warnx("%s: size mismatch, expected=%lu / actual=%lu",
ftps->ftp_remote_path,
diff --git a/usr.bin/fetch/http.c b/usr.bin/fetch/http.c
index 2f08c1d2be0f0..ecade4ef19ea6 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.19 1998/07/12 09:07:36 se Exp $
*/
#include <sys/types.h>
@@ -440,7 +440,6 @@ http_retrieve(struct fetch_state *fs)
char *base64ofmd5;
int to_stdout, restarting, redirection, retrying, autherror, chunked;
char rangebuf[sizeof("Range: bytes=18446744073709551616-\r\n")];
- int tried_head;
setup_http_auth();
@@ -449,7 +448,6 @@ http_retrieve(struct fetch_state *fs)
restarting = fs->fs_restart;
redirection = 0;
retrying = 0;
- tried_head = 0;
/*
* Figure out the timeout. Prefer the -T command-line value,
@@ -509,14 +507,7 @@ http_retrieve(struct fetch_state *fs)
} while(0)
retry:
- if (fs->fs_reportsize && !tried_head) {
- addstr(iov, n, "HEAD ");
- tried_head = 1;
- }
- else {
- addstr(iov, n, "GET ");
- tried_head = 0;
- }
+ addstr(iov, n, "GET ");
addstr(iov, n, https->http_remote_request);
addstr(iov, n, " HTTP/1.1\r\n");
/*
@@ -747,16 +738,6 @@ got100reply:
else
autherror = 407;
break;
- case 501: /* Not Implemented */
- /* If we tried HEAD, retry with GET */
- if (tried_head) {
- n = 0;
- goto retry;
- }
- else {
- errstr = safe_strdup(line);
- break;
- }
case 503: /* Service Unavailable */
if (!fs->fs_auto_retry)
errstr = safe_strdup(line);
@@ -964,23 +945,6 @@ spewerror:
fs->fs_status = "retrieving file from HTTP/1.x server";
- if (fs->fs_reportsize) {
- if (total_length == -1) {
- warnx("%s: size not known\n",
- fs->fs_outputfile);
- printf("Unknown\n");
- status = 1;
- }
- else {
- printf("%qd\n", (quad_t)total_length);
- status = 0;
- }
- fclose(remote);
- unsetup_sigalrm();
- return status;
- }
-
-
/*
* OK, if we got here, then we have finished parsing the header
* and have read the `\r\n' line which denotes the end of same.
@@ -1072,29 +1036,18 @@ http_suck(struct fetch_state *fs, FILE *remote, FILE *local,
{
static char buf[BUFFER_SIZE];
ssize_t readresult, writeresult;
- off_t remain = total_length;
-
- if (total_length == -1)
- remain = 1; /*XXX*/
do {
alarm(timo);
readresult = fread(buf, 1, sizeof buf, remote);
alarm(0);
- /*
- * If know the content-length, ignore anything more the
- * the server chooses to send us.
- */
- if (total_length != -1 && ((remain -= readresult) < 0))
- readresult += remain;
-
if (readresult == 0)
return 0;
display(fs, total_length, readresult);
writeresult = fwrite(buf, 1, readresult, local);
- } while (writeresult == readresult && remain > 0);
+ } while (writeresult == readresult);
return 0;
}
@@ -1394,14 +1347,6 @@ parse_http_date(char *string)
tm.tm_year = i - 1900;
} else {
/* Monday, 27-Jan-97 14:31:09 stuffwedon'tcareabout */
- /* Quoth RFC 2068:
- o HTTP/1.1 clients and caches should assume that an RFC-850 date
- which appears to be more than 50 years in the future is in fact
- in the past (this helps solve the "year 2000" problem).
- */
- time_t now;
- struct tm *tmnow;
- int this2dyear;
char *comma = strchr(string, ',');
char mname[4];
@@ -1423,15 +1368,6 @@ parse_http_date(char *string)
if (i >= 12)
return -1;
tm.tm_mon = i;
- /*
- * RFC 2068 year interpretation.
- */
- time(&now);
- tmnow = gmtime(&now);
- this2dyear = tmnow->tm_year % 100;
- tm.tm_year += tmnow->tm_year - this2dyear;
- if (tm.tm_year - tmnow->tm_year >= 50)
- tm.tm_year -= 100;
}
#undef digit
diff --git a/usr.bin/fetch/main.c b/usr.bin/fetch/main.c
index 8b24dad4f5c1a..6669ad03be379 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.46 1998/05/09 08:56:07 des Exp $ */
#include <sys/types.h>
@@ -52,7 +52,7 @@ static void
usage()
{
fprintf(stderr, "%s\n%s\n",
- "usage: fetch [-DHILMNPRTVablmnpqrstv] [-o outputfile] [-S bytes]",
+ "usage: fetch [-DHILMNPRTValmnpqrv] [-o outputfile] [-S bytes]",
" [-f file -h host [-c dir] | URL]");
exit(EX_USAGE);
}
@@ -71,13 +71,12 @@ main(int argc, char *const *argv)
init_schemes();
fs = clean_fetch_state;
fs.fs_verbose = 1;
- fs.fs_reportsize = 0;
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) {
+ while ((c = getopt(argc, argv, "abc:D:f:h:HilLmMnNo:pPqRrS:tT:vV:")) != -1) {
switch (c) {
- case 'D': case 'H': case 'I': case 'L': case 'N': case 'V':
+ case 'D': case 'H': case 'I': case 'N': case 'L': case 'V':
break; /* ncftp compatibility */
case 'a':
@@ -136,10 +135,6 @@ main(int argc, char *const *argv)
fs.fs_use_connect = 1;
break;
- case 's':
- fs.fs_reportsize = 1;
- break;
-
case 'S':
/* strtol sets errno to ERANGE in the case of overflow */
errno = 0;