Add the -F option. This is for forcing restarts with -r by inhibiting
transmission of the If-Range HTTP header field.
This commit is contained in:
parent
ec1b7a3596
commit
efa6f012d8
@ -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
|
||||
|
@ -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 *);
|
||||
|
@ -564,9 +564,11 @@ http_retrieve(struct fetch_state *fs)
|
||||
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);
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user