2004-11-18 change to fd_read_body
Hrvoje Niksic <[email protected]>
| Newsgroups | gmane.comp.web.wget.patches |
|---|---|
| Message-ID | <[email protected]> |
A patch by Leonid Petrov changed fd_read_body by adding these lines:
/* when retrieving from http-proxy wget sometimes does not trust the
* file length reported by server.
* this check is to tell wget not to stubbornly try to read again and
* again until another errno code was received. */
if ( ret == -1 && errno == ETIMEDOUT && sum_read == toread && toread > 0 )
break;
I believe this change is incorrect because it basically reimplements
the "rb_read_exactly" flag, in a fairly non-obvious way. The change
can also break FTP downloads, where the size is in some cases merely a
hint to provide better progress bars.
(The fairly complex treatment of timeouts in fd_read_body is due to
the code trying to provide feedback to the user even when the data
does not arrive; as long as the accumulated "timeouts" don't exceed
opt.read_timeout, the download should continue.)
This patch replaces the change with what I believe is an equivalent
one, that simply forces EXACT to always be on. It would be even
better to let the caller decide when they want EXACT, as the function
tries to do... but I'd first like to see why the patch was applied in
the first place. Did the proxy refuse to close the connection?
2005-03-15 Hrvoje Niksic <[email protected]>
* retr.c (fd_read_body): Always be "exact".
Index: src/retr.c
===================================================================
RCS file: /pack/anoncvs/wget/src/retr.c,v
retrieving revision 1.88
diff -u -r1.88 retr.c
--- src/retr.c 2005/03/04 19:34:31 1.88
+++ src/retr.c 2005/03/15 22:35:04
@@ -214,7 +214,8 @@
data arrives slowly. */
int progress_interactive = 0;
- int exact = flags & rb_read_exactly;
+ /*int exact = flags & rb_read_exactly;*/
+ int exact = 1;
wgint skip = 0;
/* How much data we've read/written. */
@@ -284,13 +285,6 @@
}
}
ret = fd_read (fd, dlbuf, rdsize, tmout);
-
- /* when retrieving from http-proxy wget sometimes does not trust the
- * file length reported by server.
- * this check is to tell wget not to stubbornly try to read again and
- * again until another errno code was received. */
- if ( ret == -1 && errno == ETIMEDOUT && sum_read == toread && toread > 0 )
- break;
if (ret == 0 || (ret < 0 && errno != ETIMEDOUT))
break; /* read error */