Date: Sun, 5 Mar 2017 12:06:46 +0000 (UTC) From: =?UTF-8?Q?Dag-Erling_Sm=c3=b8rgrav?= <des@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r314701 - head/lib/libfetch Message-ID: <201703051206.v25C6kU7047949@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201703051206.v25C6kU7047949>