wget: --no-cache option (noop) wanted

Denys Vlasenko vda.linux at googlemail.com
Wed Jun 13 15:32:24 UTC 2012


On Thu, Jun 7, 2012 at 3:30 PM, John Spencer
<maillist-busybox at barfooze.de> wrote:
> in gnu wget, it is not important if you place --options before or after the
> url, but bb wget fails.

Are you sure?

> another broken thing in busybox wget is the -c switch which should enable
> resuming of incomplete downloads, but when this option is used with a server
> that doesnt support REST it will fail to download at all. iirc this happened
> with the zlib.net server.

Proposed fix:

diff -d -urpN busybox.9/networking/wget.c busybox.a/networking/wget.c
--- busybox.9/networking/wget.c	2012-06-13 17:27:16.501002376 +0200
+++ busybox.a/networking/wget.c	2012-06-13 17:25:51.386269957 +0200
@@ -350,6 +350,14 @@ static char *gethdr(FILE *fp)
 	return hdrval;
 }

+static void reset_beg_range_to_zero(void)
+{
+	//bb_error_msg("restart failed");
+	G.beg_range = 0;
+	xlseek(G.output_fd, 0, SEEK_SET);
+	ftruncate(G.output_fd, 0);
+}
+
 static FILE* prepare_ftp_session(FILE **dfpp, struct host_info
*target, len_and_sockaddr *lsa)
 {
 	FILE *sfp;
@@ -421,6 +429,8 @@ static FILE* prepare_ftp_session(FILE **
 		sprintf(G.wget_buf, "REST %"OFF_FMT"u", G.beg_range);
 		if (ftpcmd(G.wget_buf, NULL, sfp) == 350)
 			G.content_len -= G.beg_range;
+		else
+			reset_beg_range_to_zero();
 	}

 	if (ftpcmd("RETR ", target->path, sfp) > 150)
@@ -744,6 +754,12 @@ However, in real world it was observed t
 (e.g. Boa/0.94.14rc21) simply use code 204 when file size is zero.
 */
 		case 204:
+			if (G.beg_range != 0) {
+				/* "Range:..." was not honored by the server.
+				 * Restart download from the beginning.
+				 */
+				reset_beg_range_to_zero();
+			}
 			break;
 		case 300:  /* redirection */
 		case 301:


More information about the busybox mailing list