svn commit: r314701 - head/lib/libfetch
Dag-Erling Smørgrav
des at FreeBSD.org
Sun Mar 5 12:06:47 UTC 2017
Author: des
Date: Sun Mar 5 12:06:45 2017
New Revision: 314701
URL: https://svnweb.freebsd.org/changeset/base/314701
Log:
Fix partial requests (used by fetch -r) when the requested file is
already complete.
Since 416 is an error code, any Content-Range header in the response
would refer to the error message, not the requested document, so
relying on the value of size when we know we got a 416 is wrong.
Instead, just verify that offset == 0 and assume that we've reached
the end of the document (if offset > 0, we did not request a range,
and the server is screwing with us). Note that we cannot distinguish
between reaching the end and going past it, but that is a flaw in the
protocol, not in the code, so we just have to assume that the caller
knows what it's doing. A smart caller would request an offset
slightly before what it believes is the end and compare the result to
what is already in the file.
PR: 212065
Reported by: mandree
MFC after: 3 weeks
Modified:
head/lib/libfetch/http.c
Modified: head/lib/libfetch/http.c
==============================================================================
--- head/lib/libfetch/http.c Sun Mar 5 07:46:48 2017 (r314700)
+++ head/lib/libfetch/http.c Sun Mar 5 12:06:45 2017 (r314701)
@@ -1925,7 +1925,7 @@ http_request_body(struct url *URL, const
/* requested range not satisfiable */
if (conn->err == HTTP_BAD_RANGE) {
- if (url->offset == size && url->length == 0) {
+ if (url->offset > 0 && url->length == 0) {
/* asked for 0 bytes; fake it */
offset = url->offset;
clength = -1;
More information about the svn-src-all
mailing list