A resumed transfer asks for the tail of whatever the server has now.
If the file changed in between, the caller cannot tell and ends up
with a corrupt copy.
Record the strong entity tag of each successful HTTP response in a new
validator field appended to struct url, a string that fetchFreeURL()
frees, and send it as If-Range whenever the same struct url is reused
with a non-zero offset. A server that no longer has that version then
answers 200 with the full document, which is reported through
url->offset as today. A 206 with a different entity tag fails with
the new FETCH_RESTART error code, which catches servers that honor
Range but ignore If-Range, as long as they send an entity tag. So
does a 416 to a conditional request, unless the server reports that
the document ends at the offset asked for: there is nothing left to
transfer then.
The stream returned when nothing is left to transfer now reads as
empty. It used to hand the caller the body of the 416 reply, an error
page, as if it were the rest of the document.
Only a caller that reuses the struct url benefits. fetch -a retries
send If-Range, but fetch(1) needs the change after this one to deal
with every answer; a later fetch -r run starts without a validator.
The library now frees a member of struct url, which a caller may have
allocated itself, so bump SHLIB_MAJOR to 7 and take the occasion to
enable symbol versioning: only the interfaces declared in fetch.h are
exported now, tagged FBSD_1.9.
fetch(1): do not begin a transfer which failed with FETCH_RESTART
again from main(). Begun again there, it loses the validator, and a
server which resumes but ignores If-Range is asked for the file again
for as long as its replies are cut short.
Relnotes: yes
Sponsored by: Rubicon Communications, LLC ("Netgate")