From 261183c6092a33a785cc2c6e60447845ce48da12 Mon Sep 17 00:00:00 2001
From: hniksic <devnull@localhost>
Date: Fri, 12 Dec 2003 14:55:20 -0800
Subject: [PATCH] [svn] retr.c (fd_read_body): Pass total size to
 progress_create, not the remaining amount.

---
 src/ChangeLog | 5 +++++
 src/http.c    | 2 ++
 src/retr.c    | 7 ++++---
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 4de2bc22..9a10ea46 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2003-12-12  Hrvoje Niksic  <hniksic@xemacs.org>
+
+	* retr.c (fd_read_body): Pass total size to progress_create, not
+	the remaining amount.
+
 2003-12-12  Hrvoje Niksic  <hniksic@xemacs.org>
 
 	* retr.c (fd_read_body): Don't fiddle with "interactive timeout"
diff --git a/src/http.c b/src/http.c
index e3889bb0..40a2fceb 100644
--- a/src/http.c
+++ b/src/http.c
@@ -1718,6 +1718,8 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy)
   if (keep_alive)
     flags |= rb_read_exactly;
   if (hs->restval > 0 && contrange == 0)
+    /* If the server ignored our range request, instruct fd_read_body
+       to skip the first RESTVAL bytes of body.  */
     flags |= rb_skip_startpos;
   hs->len = hs->restval;
   hs->rd_size = 0;
diff --git a/src/retr.c b/src/retr.c
index 6ea558fa..3415ff02 100644
--- a/src/retr.c
+++ b/src/retr.c
@@ -224,9 +224,10 @@ fd_read_body (int fd, FILE *out, long toread, long startpos,
 
   if (opt.verbose)
     {
-      /* If we're skipping STARTPOS bytes, hide it from
-	 progress_create because the indicator can't deal with it.  */
-      progress = progress_create (skip ? 0 : startpos, toread);
+      /* If we're skipping STARTPOS bytes, pass 0 as the INITIAL
+	 argument to progress_create because the indicator doesn't
+	 (yet) know about "skipping" data.  */
+      progress = progress_create (skip ? 0 : startpos, startpos + toread);
       progress_interactive = progress_interactive_p (progress);
     }