Bail out on unexpected 416 server errors

* src/http.c (gethttp): Stop on 416 if file is incomplete
This commit is contained in:
Josef Moellers 2017-09-18 16:45:44 +02:00 committed by Tim Rühsen
parent c451eec155
commit 6f3b995993

View File

@ -3930,6 +3930,16 @@ gethttp (const struct url *u, struct url *original_url, struct http_stat *hs,
}
}
if (statcode == HTTP_STATUS_RANGE_NOT_SATISFIABLE
&& hs->restval < (contlen + contrange))
{
/* The file was not completely downloaded,
yet the server claims the range is invalid.
Bail out. */
CLOSE_INVALIDATE (sock);
retval = RANGEERR;
goto cleanup;
}
if (statcode == HTTP_STATUS_RANGE_NOT_SATISFIABLE
|| (!opt.timestamping && hs->restval > 0 && statcode == HTTP_STATUS_OK
&& contrange == 0 && contlen >= 0 && hs->restval >= contlen))