From 928c54d27e387c6aaa249af1fa9e5a268afd06d2 Mon Sep 17 00:00:00 2001 From: Ander Juaristi Date: Thu, 16 Jun 2016 18:08:24 +0200 Subject: [PATCH] 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. --- src/http.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/http.c b/src/http.c index e6bb0dcf..00609a46 100644 --- a/src/http.c +++ b/src/http.c @@ -4335,8 +4335,13 @@ http_loop (const struct url *u, struct url *original_url, char **newloc, first attempt to clobber existing data.) */ hstat.restval = st.st_size; else if (count > 1) - /* otherwise, continue where the previous try left off */ - hstat.restval = hstat.len; + { + /* otherwise, continue where the previous try left off */ + if (hstat.len < hstat.restval) + hstat.restval -= hstat.len; + else + hstat.restval = hstat.len; + } else hstat.restval = 0;