bug-wget
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-wget] 'All buffer skipped' in write_data


From: Ángel González
Subject: [Bug-wget] 'All buffer skipped' in write_data
Date: Sat, 10 Nov 2012 19:47:48 +0100
User-agent: Thunderbird

I was having today wget failing with:
 Cannot write to 'http://www.example.org/index.html' (Success).
when running wget --continue and an existing index.html

Debugging showed the following:
- read_response_body returns FWRITEERR because fd_read_body returned -2
- fd_read_body returned -2 because write_data returned 1.
- write_data returns 1 in case of a 'generic error'

However, in this case it was returning it because *skip > bufsize, which
doesn't seem to me like an error at all.
This function has been like this since it was added to wget in 2003 by
hniksic (78706dc), when support for skipping initial STARTPOS octets
(when the server doesn't support range) was added.

So I propose to change the function to return 0 if it didn't really write
anything since all the available bytes were skipped.

Additionally, this fixes the original issue, and makes wget happily
download it. :)

diff --git a/src/retr.c b/src/retr.c
index 6204839..df6335e 100644
--- a/src/retr.c
+++ b/src/retr.c
@@ -153,7 +153,7 @@ write_data (FILE *out, FILE *out2, const char *buf,
int bufsize,
   if (*skip > bufsize)
     {
       *skip -= bufsize;
-      return 1;
+      return 0;
     }
   if (*skip)
     {
@@ -161,7 +161,7 @@ write_data (FILE *out, FILE *out2, const char *buf,
int bufsize,
       bufsize -= *skip;
       *skip = 0;
       if (bufsize == 0)
-        return 1;
+        return 0;
     }
 
   if (out != NULL)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]