Do not overwrite restval if len is smaller

* src/http.c (http_loop): overwrite 'restval' only if 'len' is
   greater than it. Else substract 'len' to 'restval'.

When retrying a request, only send a 'Range' header if the previous
request returned data.
This commit is contained in:
Ander Juaristi 2016-06-16 18:08:24 +02:00 committed by Tim Rühsen
parent 33bc3aae51
commit 928c54d27e

View File

@ -4335,8 +4335,13 @@ http_loop (const struct url *u, struct url *original_url, char **newloc,
first attempt to clobber existing data.) */ first attempt to clobber existing data.) */
hstat.restval = st.st_size; hstat.restval = st.st_size;
else if (count > 1) else if (count > 1)
{
/* otherwise, continue where the previous try left off */ /* otherwise, continue where the previous try left off */
if (hstat.len < hstat.restval)
hstat.restval -= hstat.len;
else
hstat.restval = hstat.len; hstat.restval = hstat.len;
}
else else
hstat.restval = 0; hstat.restval = 0;