summaryrefslogtreecommitdiffstats
path: root/usr.bin/fetch
diff options
context:
space:
mode:
authorgreen <green@FreeBSD.org>1999-10-23 15:22:53 +0000
committergreen <green@FreeBSD.org>1999-10-23 15:22:53 +0000
commitb6ebb73004de327dc34a9cb5b12dd55f933a8e20 (patch)
treec5eb081c16dd6dc380bd12ce38e924d796eb1458 /usr.bin/fetch
parent732f8d1ced1c1a73c458f8c126d3933903c41526 (diff)
downloadFreeBSD-src-b6ebb73004de327dc34a9cb5b12dd55f933a8e20.zip
FreeBSD-src-b6ebb73004de327dc34a9cb5b12dd55f933a8e20.tar.gz
Add the -F option. This is for forcing restarts with -r by inhibiting
transmission of the If-Range HTTP header field.
Diffstat (limited to 'usr.bin/fetch')
-rw-r--r--usr.bin/fetch/fetch.112
-rw-r--r--usr.bin/fetch/fetch.h1
-rw-r--r--usr.bin/fetch/http.c8
-rw-r--r--usr.bin/fetch/main.c8
4 files changed, 22 insertions, 7 deletions
diff --git a/usr.bin/fetch/fetch.1 b/usr.bin/fetch/fetch.1
index 40b6835..919b559 100644
--- a/usr.bin/fetch/fetch.1
+++ b/usr.bin/fetch/fetch.1
@@ -7,14 +7,14 @@
.Nd retrieve a file by Uniform Resource Locator
.Sh SYNOPSIS
.Nm fetch
-.Op Fl AMPablmnpqrtv
+.Op Fl AFMPablmnpqrtv
.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 FMPRlmnpqrv
.Op Fl S Ar size
.Op Fl o Ar file
.Op Fl c Ar dir
@@ -65,6 +65,14 @@ protocol.
The file to retrieve is in directory
.Ar dir
on the remote host.
+.It Fl F
+Force restart without checking for the local file's date matching
+that of the remote file. Use this with
+.Fl r
+to restart a transfer of a partial file where the modification
+time on the local file has been changed and you are sure that the
+remote file is still the same, as this will prevent retrieval from
+starting anew.
.It Fl f Ar file
The file to retrieve is named
.Ar file
diff --git a/usr.bin/fetch/fetch.h b/usr.bin/fetch/fetch.h
index bea7db9..22e4294 100644
--- a/usr.bin/fetch/fetch.h
+++ b/usr.bin/fetch/fetch.h
@@ -53,6 +53,7 @@ struct fetch_state {
int fs_use_connect; /* -t option */
off_t fs_expectedsize; /* -S option */
int fs_reportsize; /* -s option */
+ int fs_forcerestart; /* -F option */
time_t fs_modtime;
void *fs_proto;
int (*fs_retrieve)(struct fetch_state *);
diff --git a/usr.bin/fetch/http.c b/usr.bin/fetch/http.c
index 4e19485..3025ecc 100644
--- a/usr.bin/fetch/http.c
+++ b/usr.bin/fetch/http.c
@@ -564,9 +564,11 @@ retry:
if (((!to_stdout && stat(fs->fs_outputfile, &stab) == 0)
|| (to_stdout && fstat(STDOUT_FILENO, &stab) == 0))
&& S_ISREG(stab.st_mode)) {
- addstr(iov, n, "If-Range: ");
- addstr(iov, n, format_http_date(stab.st_mtime));
- addstr(iov, n, "\r\n");
+ if (!fs->fs_forcerestart) {
+ addstr(iov, n, "If-Range: ");
+ addstr(iov, n, format_http_date(stab.st_mtime));
+ addstr(iov, n, "\r\n");
+ }
sprintf(rangebuf, "Range: bytes=%qd-\r\n",
(long long)stab.st_size);
addstr(iov, n, rangebuf);
diff --git a/usr.bin/fetch/main.c b/usr.bin/fetch/main.c
index 7cae99b..63c7aee 100644
--- a/usr.bin/fetch/main.c
+++ b/usr.bin/fetch/main.c
@@ -52,7 +52,7 @@ static void
usage(void)
{
fprintf(stderr,
- "usage: fetch [-ADHILMNPRTVablmnpqrstv] [-o outputfile] "
+ "usage: fetch [-ADHILMNPRTVablFmnpqrstv] [-o outputfile] "
"[-S bytes]\n"
" [-f file -h host [-c dir] | URL]\n");
exit(EX_USAGE);
@@ -76,7 +76,7 @@ main(int argc, char *const *argv)
fs.fs_expectedsize = -1;
change_to_dir = file_to_get = hostname = 0;
-#define OPT_STRING "Aabc:D:f:h:HIlLmMnNo:pPqRrS:stT:vV:"
+#define OPT_STRING "Aabc:D:Ff:h:HIlLmMnNo:pPqRrS:stT:vV:"
while ((c = getopt(argc, argv, OPT_STRING)) != -1) {
switch (c) {
case 'A':
@@ -86,6 +86,10 @@ main(int argc, char *const *argv)
case 'D': case 'H': case 'I': case 'L': case 'N': case 'V':
break; /* ncftp compatibility */
+ case 'F':
+ fs.fs_forcerestart = 1;
+ break;
+
case 'a':
fs.fs_auto_retry = 1;
break;
OpenPOWER on IntegriCloud