History log of /freebsd-current/usr.bin/fetch/fetch.c
Revision Date Author Comments
# 5e3934b1 24-Nov-2023 Warner Losh <imp@FreeBSD.org>

usr.bin: Automated cleanup of cdefs and other formatting

Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by: Netflix


# 1d386b48 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# 32066c96 20-Feb-2022 Stefan Eßer <se@FreeBSD.org>

fetch: make -S argument accept values > 2GB

Use strtoll() to parse the argument of the -S option.

FreeBSD has supported 64 bit file offsets for more than 25 years on
all architectures and off_t is a 64 bit integer type for that reason.

While strtol() returns a 64 bit value on 64 LP64 architectures, it
is limit to 32 bit on e.g. i386. The strtoll() function returns a 64
but result on all supported architectures and therefore supports the
possible file lengths and file offsets on 32 bit archtectures.

Reported by: antoine
MFC after: 3 days


# 85f15576 24-Jan-2022 Eugene Grosbein <eugen@FreeBSD.org>

fetch(1): more fixes for soft failure handling

Fix logic error introduced in my commit
bf599c03f09dea0f7e188e002b42d782af6841c3

Also, authorization errors should not be considered as soft failures.


# 08a2504a 24-Jan-2022 Eugene Grosbein <eugen@FreeBSD.org>

fetch(1): fix error in previous commit

strncmp() compares terminating zero and sizeof() includes it.
Un-obsfuscate the code and show what it is indended to do.


# bf599c03 24-Jan-2022 Eugene Grosbein <eugen@FreeBSD.org>

fetch(1): do not consider HTTP 5XX errors as soft failures

This change fixes "fetch -a" looping forever on "502 Bad gateway"
error and similar.

MFC after: 1 month


# a4efbe0d 23-Jan-2022 Eugene Grosbein <eugen@FreeBSD.org>

fetch(1): correct progress accounting after previous commit

MFC after: 1 month


# e3bad5f7 23-Jan-2022 Eugene Grosbein <eugen@FreeBSD.org>

fetch(1): process truncated transfer as soft failure

Let "fetch -a" resume truncated transfer automatically
perform another attempt if it obtained some new data in previous one
making progress.

This makes it more robust against frequent but transient network failures.
For example:

=> sqlite-src-3370200.zip doesn't seem to exist in /usr/ports/distfiles/.
=> Attempting to fetch https://www.sqlite.org/2022/sqlite-src-3370200.zip
sqlite-src-3370200.zip 3% of 12 MB 45 kBps 04m24s
fetch: sqlite-src-3370200.zip appears to be truncated: 524288/13145234 bytes
sqlite-src-3370200.zip 10% of 12 MB 67 kBps 02m56s
fetch: sqlite-src-3370200.zip appears to be truncated: 1327104/13145234 bytes
sqlite-src-3370200.zip 28% of 12 MB 123 kBps 01m14s
fetch: sqlite-src-3370200.zip appears to be truncated: 3735552/13145234 bytes
sqlite-src-3370200.zip 54% of 12 MB 253 kBps 24s
fetch: sqlite-src-3370200.zip appears to be truncated: 7176192/13145234 bytes
sqlite-src-3370200.zip 62% of 12 MB 90 kBps 55s
fetch: sqlite-src-3370200.zip appears to be truncated: 8241152/13145234 bytes
sqlite-src-3370200.zip 82% of 12 MB 113 kBps 20s
fetch: sqlite-src-3370200.zip appears to be truncated: 10862592/13145234 bytes
sqlite-src-3370200.zip 12 MB 185 kBps 12s
===> Fetching all distfiles required by sqlite3-3.37.2,1 for building

MFC after: 1 month


# 6434dda6 10-Sep-2018 Dag-Erling Smørgrav <des@FreeBSD.org>

Through a combination of insufficient variable initialization and
imprudent reuse of static buffers, the end-of-transfer statistics
displayed when stdout is not a tty always ended up as 0 B / 0 Bps.
Reorganize the code to use caller-provided buffers, tweak the ETA
display a bit, and reduce the visual differences between the tty and
non-tty end-of-transfer displays.

PR: 202424
Approved by: re (gjb@)


# deb1ff23 12-May-2018 Dag-Erling Smørgrav <des@FreeBSD.org>

Support If-Modified-Since for https as well as http.

PR: 224426
Submitted by: zsnafzig@edu.uwaterloo.ca
MFC after: 1 week


# 1de7b4b8 27-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

various: general adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

No functional change intended.


# 01ed3ca3 25-Mar-2015 Jung-uk Kim <jkim@FreeBSD.org>

Remove defunct SSLv2 support from fetch(1) and fetch(3).


# c2ea176d 28-Jan-2014 Dag-Erling Smørgrav <des@FreeBSD.org>

Increase the default (and minimum) buffer size from 4 kB to 16 kB. Also,
propagate the buffer size to libc, which uses a 1 kB buffer by default,
negating any hypothetical benefit of increasing fetch(1)'s buffer size.

MFC after: 3 days


# 2043423c 28-Jan-2014 Dag-Erling Smørgrav <des@FreeBSD.org>

whitespace and bump copyright


# dcd47379 26-Jul-2013 Dag-Erling Smørgrav <des@FreeBSD.org>

Implement certificate verification, and many other SSL-related
imrovements; complete details in the PR.

PR: kern/175514
Submitted by: Michael Gmelin <freebsd@grem.de>
MFC after: 1 week


# a96469b7 02-Jun-2013 Eitan Adler <eadler@FreeBSD.org>

Correct check to see if file changes.

Reported by: swildner@DragonFlyBSD.org
Reviewed by: des


# 162361c1 09-Dec-2012 Andre Oppermann <andre@FreeBSD.org>

Fix bandwidth reporting when doing a restarted download with "-r".
The offset is already accounted for in xs->lastrcvd and doesn't
have to be subtracted again.

Reported by: Florian Smeets <flo@smeets.im>
Submitted by: Mateusz Guzik <mjguzik@gmail.com>
Tested by: Florian Smeets <flo@smeets.im>
MFC after: 1 week


# 2214137a 08-Dec-2012 Eitan Adler <eadler@FreeBSD.org>

Add check for failure of mkstemp and setenv.

Reviewed by: des
Approved by: cperciva (implicit)
Obtained from: DragonFlyBSD
MFC after: 1 week


# ae7dc19c 15-Nov-2012 Andre Oppermann <andre@FreeBSD.org>

Change fetch(1) to:

o Report the instantaneous bandwidth instead of an average since the
beginning of the download.

o At the finish of the download report the average bandwidth and also
the total time it took instead of 00m00s.

Reviewed by: des
MFC after: 1 week


# bf70bece 19-Oct-2012 Ed Schouten <ed@FreeBSD.org>

More -Wmissing-variable-declarations fixes.

In addition to adding `static' where possible:

- bin/date: Move `retval' into extern.h to make it visible to date.c.
- bin/ed: Move globally used variables into ed.h.
- sbin/camcontrol: Move `verbose' into camcontrol.h and fix shadow warnings.
- usr.bin/calendar: Remove unneeded variables.
- usr.bin/chat: Make `line' local instead of global.
- usr.bin/elfdump: Comment out unneeded function.
- usr.bin/rlogin: Use _Noreturn instead of __dead2.
- usr.bin/tset: Pull `Ospeed' into extern.h.
- usr.sbin/mfiutil: Put global variables in mfiutil.h.
- usr.sbin/pkg: Remove unused `os_corres'.
- usr.sbin/quotaon, usr.sbin/repquota: Remove unused `qfname'.


# 2a7daafe 18-Jan-2012 Dag-Erling Smørgrav <des@FreeBSD.org>

Fix two issues related to the use of SIGINFO in fetch(1) to display
progress information. The first is that fetch_read() (used in the HTTP
code but not the FTP code) can enter an infinite loop if it has previously
been interrupted by a signal. The second is that when it is interrupted,
fetch_read() will discard any data it may have read up to that point.
Luckily, both bugs are extremely timing-sensitive and therefore difficult
to trigger.

PR: bin/153240
Submitted by: Mark <markjdb@gmail.com>
MFC after: 3 weeks


# bb6e3329 27-Sep-2011 Dag-Erling Smørgrav <des@FreeBSD.org>

Document the fact that passive mode is now the default.
Update copyright dates and strip my middle name.


# 5c5052cc 27-Sep-2011 Dag-Erling Smørgrav <des@FreeBSD.org>

Use fseeko() instead of fseek(). The rest of the code is off_t-aware,
but the use of fseek() means fetch(1) can't correctly resume a transfer
that was interrupted past the 2 GB mark.

Pointed out by: ache@
MFC after: 3 weeks


# 27274e81 27-Sep-2011 Dag-Erling Smørgrav <des@FreeBSD.org>

Followup to r225599: the fseek() was a no-op since the file was opened
in append mode. Open it in read-write mode instead. Also move the
fseek up one level to cover the (unlikely but not impossible) case where
the server accepts ranges but does not send a Content-Size header.

PR: bin/117277
MFC after: 3 weeks


# a17e51c1 15-Sep-2011 Dag-Erling Smørgrav <des@FreeBSD.org>

When resuming an HTTP download, we failed to verify that the range
returned by the server matched what we requested, and blindly appended
what we received to what we already had. This could go two ways: if the
delivered offset was higher than expected, the local file would contain
duplicate data, while if it was lower than expected, there would be data
missing from the middle of the file. Furthermore, if the transfer was
interrupted again, each subsequent attempt would compound the error.
Fix the first problem by restarting the transfer from scratch if there
is a gap, and the second by explicitly seeking to the correct location
in the local file so as to overwrite any duplicated data.

PR: bin/117277
Approved by: re (kib)
MFC after: 3 weeks


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# fe0506d7 09-Mar-2010 Marcel Moolenaar <marcel@FreeBSD.org>

Create the altix project branch. The altix project will add support
for the SGI Altix 350 to FreeBSD/ia64. The hardware used for porting
is a two-module system, consisting of a base compute module and a
CPU expansion module. SGI's NUMAFlex architecture can be an excellent
platform to test CPU affinity and NUMA-aware features in FreeBSD.


# c7fabb71 06-Jan-2010 Ruslan Ermilov <ru@FreeBSD.org>

MFC r201290: Treat an empty argument as an error, instead of
fetching the contents of the root directory.


# 8181961a 30-Dec-2009 Ruslan Ermilov <ru@FreeBSD.org>

Treat an empty argument as an error, instead of fetching the
contents of the root directory.

MFC after: 1 week


# 821df508 12-Dec-2009 Xin LI <delphij@FreeBSD.org>

Revert most part of 200420 as requested, as more review and polish is
needed.


# 6f2d3221 11-Dec-2009 Xin LI <delphij@FreeBSD.org>

Remove unneeded header includes from usr.bin/ except contributed code.

Tested with: make universe


# 31871958 17-Jan-2009 Dag-Erling Smørgrav <des@FreeBSD.org>

The FTP_TIMEOUT and HTTP_TIMEOUT environment variables were ignored because
T_secs already had a non-zero default. Unbreak by moving the default to
ftp_timeout / http_timeout.

Submitted by: Christoph Mallon <christoph.mallon@gmx.de>
MFC after: 2 weeks


# e8f612b6 17-Dec-2008 Murray Stokely <murray@FreeBSD.org>

1. Update fetch to consistently return 1 on error, as the man page states,
rather than usually returning 1 but in a few instances using a sysexits(3)
return value.

2. Remove a few unused variables from libfetch.

PR: docs/122470 (1, only)
Reviewed by: des


# 7f92799f 15-Dec-2008 Murray Stokely <murray@FreeBSD.org>

Add support for HTTP 1.1 If-Modified-Since behavior.

fetch(1) accepts a new argument -i <file> that if specified will cause
the file to be downloaded only if it is more recent than the mtime of
<file>.

libfetch(3) accepts the mtime in the url structure and a flag to
indicate when this behavior is desired.

PR: bin/87841
Submitted by: Jukka A. Ukkonen <jau@iki.fi> (partially)
Reviewed by: des, ru
MFC after: 3 weeks


# e801aa48 13-Dec-2008 Ruslan Ermilov <ru@FreeBSD.org>

Improve usage and sync SYNOPSIS with usage.


# 2b8907e7 10-Dec-2008 Dag-Erling Smørgrav <des@FreeBSD.org>

Apply the same defaults to https as to http.

Submitted by: Mike Tancsa <mike@sentex.net>
MFC after: 1 week


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# 8acee1c0 21-Aug-2008 David E. O'Brien <obrien@FreeBSD.org>

Use the SCHEME_ knobs rather than knowing what they expand to.

Reviewed by: des


# 1bac3abc 10-Nov-2006 Dag-Erling Smørgrav <des@FreeBSD.org>

Try to preserve ownership and permissions when replacing an existing file.

PR: bin/104702
Submitted by: Kevin Day <toasty@dragondata.com>
MFC after: 1 week


# 15e2d64e 30-Dec-2005 Dag-Erling Smørgrav <des@FreeBSD.org>

Only clear sb.st_size if it is clearly wrong or meaningless. This fixes
mirror mode.

PR: bin/86940
MFC after: 2 weeks


# 0c878744 30-Dec-2005 Dag-Erling Smørgrav <des@FreeBSD.org>

Reflect progress in process title.

Submitted by: flz
MFC after: 2 weeks


# 8c355b08 17-Nov-2004 Colin Percival <cperciva@FreeBSD.org>

Fix buffer overflow. This is FreeBSD-SA-04:16.fetch.

Approved by: des


# 2cbbf9da 21-Sep-2004 Dag-Erling Smørgrav <des@FreeBSD.org>

Update copyright years.


# 44336f2f 26-Aug-2004 Dag-Erling Smørgrav <des@FreeBSD.org>

The check for r_flag was accidentally removed in the previous commit.

Submitted by: SANETO Takanori <sanewo@ba2.so-net.ne.jp>
MFC after: 3 days


# 13901dd2 15-Aug-2004 Dag-Erling Smørgrav <des@FreeBSD.org>

Fix a couple of edge cases in which sb.st_size may be incorrect or
meaningless. In particular, don't assume that it is left untouched if
stat(2) fails; that assumption happens to fail at high optimization
levels on some platforms.

MFC after: 1 week


# e9aa05f1 27-Jul-2004 Dag-Erling Smørgrav <des@FreeBSD.org>

Don't strip trailing linear whitespace from passwords.

MFC after: 2 weeks


# ebeb3bab 27-Jul-2004 Dag-Erling Smørgrav <des@FreeBSD.org>

Style nits.


# c8488e24 05-Jul-2004 Dag-Erling Smørgrav <des@FreeBSD.org>

Truncate long file names in stat_display(), as was originally intended.

MFC after: 1 week


# adce61f9 24-Jun-2004 Dag-Erling Smørgrav <des@FreeBSD.org>

The description of the -S option in the man page says we won't fail if the
remote size is unknown, but we do. Resolve this in the man page's favor.

Requested by: Andre Albsmeier <andre.albsmeier@siemens.com>
MFC after: 1 week


# be28a6af 19-May-2004 Lukas Ertl <le@FreeBSD.org>

Fix integer overflow in the file size output when dealing with
large files (i.e. DVD images).

Reviewed by: des@


# 3d493842 05-Apr-2004 Dag-Erling Smørgrav <des@FreeBSD.org>

Workaround for servers that ignore byte ranges when using chunked
encoding.

MFC after: 3 days


# 5476ba55 18-Feb-2004 Dag-Erling Smørgrav <des@FreeBSD.org>

Use %zu for size_t, like God intended.


# eae1afd9 18-Feb-2004 Dag-Erling Smørgrav <des@FreeBSD.org>

Fix printf() format bug in previous commit (size_t != int).
Use %ju and an (uintmax_t) cast to print size_t values.
Use %jd and an (intmax_t) cast to print off_t values.
Use off_t variables to hold the difference between two off_t values.
Don't bother with unsigned char where char will do nicely.


# 3f59deaf 18-Feb-2004 Dag-Erling Smørgrav <des@FreeBSD.org>

Revamp the statistics code, and switch to a much more compact display
format. The old code tried to produce the exact same output as the
pre-libfetch implementation, but I no longer see any value in this.


# b12d1620 11-Mar-2003 Dag-Erling Smørgrav <des@FreeBSD.org>

Use floating point arithmetic to compute the ETA to avoid integer overflow
during slow transfers of large files.


# 29568c01 11-Mar-2003 Dag-Erling Smørgrav <des@FreeBSD.org>

Clean up the ETA logic a bit and make sure it works for restarted transfers.


# 32c8cd29 23-Jan-2003 Dag-Erling Smørgrav <des@FreeBSD.org>

Slight cleanup of the ETA / BPS code. Avoid a division by zero.


# 13da7d99 22-Jan-2003 Dag-Erling Smørgrav <des@FreeBSD.org>

Add -N option to specify a netrc file.
Fix handling of -v option.
Don't treat negative offsets as valid positive ones.
Clean up the ETA and transfer rate code. Show transfer rate along with
ETA if the verbose level is higher than 1.


# 3d7c408c 27-Nov-2002 Dag-Erling Smørgrav <des@FreeBSD.org>

Use the URL instead of the output file name when reporting errors relating
to the remote document.

PR: 33856
MFC after: 1 week
Approved by: re


# a6266f24 13-Nov-2002 Dag-Erling Smørgrav <des@FreeBSD.org>

Don't set atime / mtime if we don't have an output file, which can happen
in certain failure scenarii (mostly DNS trouble).


# f10d3c51 12-Nov-2002 Bill Fenner <fenner@FreeBSD.org>

Don't divide by zero to calculate the ETA, even if we haven't gotten
any data in 30 seconds.


# 05f45e0c 07-Nov-2002 Bill Fenner <fenner@FreeBSD.org>

Don't exit with success after timeout during authentication.


# eb87c5a7 27-Oct-2002 Dag-Erling Smørgrav <des@FreeBSD.org>

Don't complain about not knowing the remote file size when working in
quiet mode.

PR: bin/37079
Submitted by: Nicolas Rachinsky <list@rachinsky.de>


# 97727a7d 27-Oct-2002 Dag-Erling Smørgrav <des@FreeBSD.org>

Whitespace and indentation cleanup.


# 0c6d34af 27-Oct-2002 Dag-Erling Smørgrav <des@FreeBSD.org>

Forgot to disable alarms after fetchXGet() in previous commit.


# dc161d55 27-Oct-2002 Dag-Erling Smørgrav <des@FreeBSD.org>

Add an ETA timer that kicks in after 30 seconds.

Re-add alarm(2) calls around the calls to fetchStat(3) and fetchXGet(3),
since these calls can still time out on DNS lookups or TCP connect(2).

Remove the alarm(2) calls in the main loop, since all methods properly
handle transfer timeouts (as opposed to connection timeouts).

Set the sigalrm flag if a timeout occurs in the main loop.

Move the signal: label up a little so we still set the atime and mtime
when the transfer times out or is interrupted, so that restarted transfers
will work as expected (as long as the file still exists).

MFC after: 2 weeks


# dacff752 27-Aug-2002 Dag-Erling Smørgrav <des@FreeBSD.org>

s/optarg/s/ (cut'n'paste braino)

Spotted by: kris


# 32411a1b 28-Jul-2002 Dag-Erling Smørgrav <des@FreeBSD.org>

Use strtol(3) instead of a home-grown version, and fix a "possibly
unitialized variable" warning.


# d3974088 22-Apr-2002 Dag-Erling Smørgrav <des@FreeBSD.org>

Usage style sweep: spell "usage" with a small 'u'.
Also change one case of blatant __progname abuse (several more remain)
This commit does not touch anything in src/{contrib,crypto,gnu}/.


# 05eb0358 26-Mar-2002 Bruce Evans <bde@FreeBSD.org>

Restored the part of 1.45 that was clobbered in rev.1.46:
#include <sys/time.h> instead of depending on namespace pollution in
<sys/stat.h> for the declaration of struct timeval.


# 15baa31a 25-Mar-2002 Philippe Charnier <charnier@FreeBSD.org>

Add FBSDID. Remove unused include. Getopt returns -1 not EOF.


# 469a4570 24-Feb-2002 Bruce Evans <bde@FreeBSD.org>

#include <sys/time.h> instead of depending on namespace pollution in
<sys/stat.h> for the declaration of struct timeval.

Removed unused includes (<time.h> doesn't declare anything of interest;
only <sys/time.h> does).

Sorted includes a bit.


# 8e7cf3de 16-Feb-2002 Dag-Erling Smørgrav <des@FreeBSD.org>

If downloading to a temporary file, set the timestamp on the temp file, not
on the file we're replacing.

PR: bin/34992
Submitted by: Shunichiro Ariura <syun1rou@blackshell.org>
MFC after: 1 week


# 62f6d0b8 09-Dec-2001 Dag-Erling Smørgrav <des@FreeBSD.org>

Set fetchDebug if v_level is 3 or more.

PR: bin/32615
MFC after: 1 week


# 650b9e0e 10-Nov-2001 Ian Dowse <iedowse@FreeBSD.org>

Remove an extraneous argument to fprintf that -Wformat noticed.

Reviewed by: des


# f2a871e7 02-Nov-2001 Dag-Erling Smørgrav <des@FreeBSD.org>

Remove a debugging warnx() that got committed by mistake.


# dbcc1983 23-Sep-2001 Dag-Erling Smørgrav <des@FreeBSD.org>

Don't print running stats unless we're the foreground process.

PR: 30764


# 1c93d61f 10-Sep-2001 Mike Barcroft <mike@FreeBSD.org>

Add a cast to silence a warning (error because of WARNS=2) on Alpha.

Discussed with: des


# e9dc4f3b 08-Sep-2001 Dag-Erling Smørgrav <des@FreeBSD.org>

If the local file does not exist, or is a regular file, and we're not trying
to resume a transfer, download the requested document into a temporary file
which we later rename. This avoids leaving half-completed files around in
case of a crash (it'll still leave a half-completed file, but with a hope-
fully non-conflicting name), and should reduce the need for human inter-
vention on ports-building machines.

The temporary file name for "foo/bar" is constructed by invoking mkstemps()
with the pattern "foo/.fetch.XXXXXX.bar"

Requested by: obrien


# eab5a804 18-Aug-2001 Dag-Erling Smørgrav <des@FreeBSD.org>

Remove a blank line that snuck in with the previous commit.
Set the default timeout to 120 seconds instead of 0 (no timeout).


# db695db7 17-Aug-2001 Dag-Erling Smørgrav <des@FreeBSD.org>

Add some comments.


# 6d64e939 28-Jul-2001 Stefan Eßer <se@FreeBSD.org>

Include value of command line argument that causes an error message or
warning in said message, since fetch may be run from a makefile or script
which does not print the command line.

Approved by: des


# 04d12c99 17-Jul-2001 Dag-Erling Smørgrav <des@FreeBSD.org>

If we're writing to stdout, we don't care about the size.

Submitted by: wollman


# 91404f38 17-Jul-2001 Dag-Erling Smørgrav <des@FreeBSD.org>

WARNS cleanup + remove an unused macro and an unused function argument.


# 74bd3d76 08-Jul-2001 Dag-Erling Smørgrav <des@FreeBSD.org>

Fix an embarassing if-test-reversal bug that broke scheme guessing.


# 1a4a0639 01-Jun-2001 Dag-Erling Smørgrav <des@FreeBSD.org>

Don't try to print a completion percentage for zero-size files.

PR: 27780
Submitted by: Craig Leres <leres@ee.lbl.gov>


# 5ef824ed 27-May-2001 Dag-Erling Smørgrav <des@FreeBSD.org>

Damn. Fix typo in previous commit.


# 0d60c709 26-May-2001 Dag-Erling Smørgrav <des@FreeBSD.org>

When running on a tty, install an authentication callback.


# dde0dff6 28-Mar-2001 Dag-Erling Smørgrav <des@FreeBSD.org>

Bring the usage message in synch with reality.

PR: bin/26160


# 7c480c6c 23-Mar-2001 Dag-Erling Smørgrav <des@FreeBSD.org>

Now that libfetch uses the high port range by default, add a -U option to
make it use the low (default) port range instead.


# cd400b67 06-Mar-2001 Dag-Erling Smørgrav <des@FreeBSD.org>

If SIGINFO is received during the transfer, print a status line similar
to the summary shown at the end of the transfer.

Some days, I really hate Unix...

Suggested by: cracauer


# 89a70fbe 22-Dec-2000 Dag-Erling Smørgrav <des@FreeBSD.org>

Warn if the size of the remote file isn't known.
If the -R option was specified, don't truncate the local file even if its
mtime is incorrect.

PR: bin/23719


# 64638f67 13-Dec-2000 Dag-Erling Smørgrav <des@FreeBSD.org>

If the URL did not specify a scheme, try to guess it from the host name.


# 30204f98 30-Nov-2000 Dag-Erling Smørgrav <des@FreeBSD.org>

If the transfer timed out, but we don't know how large the file is supposed
to be, assume it was truncated.


# a6f339d2 27-Nov-2000 Kris Kennaway <kris@FreeBSD.org>

Format string auditing


# a0c6ec97 19-Oct-2000 Dag-Erling Smørgrav <des@FreeBSD.org>

Understand the difference between an empty file and a non-existent file.
This has been sitting in my tree for ages...


# 74912943 02-Sep-2000 Dag-Erling Smørgrav <des@FreeBSD.org>

Don't try to set the mtime of the output file if it's not a regular file.

Pointed out by: cwt


# e2b41a62 31-Aug-2000 Dag-Erling Smørgrav <des@FreeBSD.org>

Don't unlink the target file if it's not a regular file.


# 9516ffa7 26-Jul-2000 Dag-Erling Smørgrav <des@FreeBSD.org>

Restore the old semantics of deleting the output file when interrupted.
Some people liked this and some didn't, so POLA won.


# 32190ef5 21-Jul-2000 Dag-Erling Smørgrav <des@FreeBSD.org>

Don't print summary in quiet mode.


# d939bf77 21-Jul-2000 Dag-Erling Smørgrav <des@FreeBSD.org>

Don't display a running count in quiet mode.
Don't add the offset to the size; it's libfetch's job to report the correct
size of the requested file.


# 10e3b1c7 19-Jul-2000 Dag-Erling Smørgrav <des@FreeBSD.org>

Fix two bugs related to resumed transfers:

- if the dates didn't match, fetch would append the received file to the
existing file instead of replacing it.

- if the local file was complete and up-to-date, fetch would miscalculate
the expected size and report a failure instead of a success, because it
had no way of knowing that the server was actually resending the entire
file since the requested offset was invalid.


# a5e3ae21 19-Jul-2000 Dag-Erling Smørgrav <des@FreeBSD.org>

Braino: don't use passive mode unless the user requests it.

PR: bin/20025
Submitted by: HIYAMA Takeshi <th@cis.ibaraki.ac.jp>


# 45b22b2a 17-Jul-2000 Dag-Erling Smørgrav <des@FreeBSD.org>

While I'm at it, break a line that was too long, remove a pointless diagnostic
and adjust the verbosity level of another.


# e9a039c2 17-Jul-2000 Dag-Erling Smørgrav <des@FreeBSD.org>

Rearrange / rewrite large portions of fetch() to take advantage of new
libfetch features (fetchRestartCalls, fetchXGet()).

Since it doesn't make much sense to have m_flag and r_flag set at the same
time, and it can actually cause trouble in some cases, die if they're both
set.

Set the SA_RESETHAND flag for SIGINT so that when we've caught one, we can
kill ourselves with a second SIGINT (thus notifying our parent of our tragic
fate) instead of just exiting.

These changes fix several problems that would show up when fetching ports,
as well as speeding up HTTP transfers quite a bit (at least for relatively
small files).

Most of these changes were prompted by an interaction problem with an HTTP
server called SWS-1.0, which exhibited two bugs, the first of which prevented
fetch from working around the second (the first was not sending content-type
in reply to HEAD requests, the second was sending garbage after the end of
the requested file).


# 78394463 15-Jul-2000 Dag-Erling Smørgrav <des@FreeBSD.org>

Better signal handling.

Submitted by: green


# b3c141fd 13-Jul-2000 Dag-Erling Smørgrav <des@FreeBSD.org>

Fix a bug in the stats display that showed up when resuming aborted transfers.

Submitted by: green


# 49e62d8f 12-Jul-2000 Dag-Erling Smørgrav <des@FreeBSD.org>

Rework the stats code for the nth time. Much cleaner now.
Always display the completion percentage if stderr is a tty.
Drop the char-by-char transfer mode, it was based on an incorrect assumption
regarding the semantics of fread().
Finally (I hope) straighten out the business of setting the mtime, as well as
when to remove the output file and when not to.
Thanks are owed to the many who have provided nearly instantaneous and
highly constructive feedback and suggestions about these matters.


# ef50a72c 12-Jul-2000 Dag-Erling Smørgrav <des@FreeBSD.org>

Now that the HTTP code supports timeouts, we don't need to use alarm()
around the call to fetchStat().
Catch SIGINT, and rework the signal handling so it doesn't skimp on the
cleanup after a timeout or interrupt. Also, don't just bail out after a
timeout; there may be more files to fetch.


# aa4b3574 12-Jul-2000 Dag-Erling Smørgrav <des@FreeBSD.org>

Rework the stats code to avoid code duplication.
Fix a bug where the stats code would print the expected size instead of the
number of bytes received.
Fix the reading code so it'll support partial reads.


# ec850e74 09-Jul-2000 Dag-Erling Smørgrav <des@FreeBSD.org>

Don't segfault if given an invalid URL (doh!)

Submitted by: green


# bb11a878 08-Jul-2000 Dag-Erling Smørgrav <des@FreeBSD.org>

Straighten out the behvaiour of -m and -n (thanks to bde).
Check that stderr, not stdout, is a tty (thanks to green).


# a8369cd9 29-Jun-2000 Dag-Erling Smørgrav <des@FreeBSD.org>

Implement the -c option


# df6f33d1 29-Jun-2000 Dag-Erling Smørgrav <des@FreeBSD.org>

Don't forget to delete the output file if the request fails.
Don't delete the output file if -r was specified.


# b39628e7 28-Jun-2000 Dag-Erling Smørgrav <des@FreeBSD.org>

New libfetch-based fetch.