Hi BusyBox Team,

First and foremost, thank you all for your excellent work! It is appreciated 
tremendously.

There is a small bug in `wget' applet.

In GNU wget[1], `--spider' first issues a HEAD request, then iff HEAD fails, 
issues a GET request. In Busybox wget, only a GET request is sent. According to 
the HTTP spec[2], Busybox wget impl is technically correct. However, it causes 
portability problems. Interestingly, GNU wget man page[3] does not explicitly 
specify HTTP method.

Attached is patch to fix. Note: this is still not totally compatible with GNU 
wget because it does not retry with GET if HEAD fails.

Thank you,
Jake

[1] https://git.savannah.gnu.org/cgit/wget.git/tree/src/http.c#n4304
[2] https://httpwg.org/specs/rfc7231.html#HEAD
[3] https://www.gnu.org/software/wget/manual/wget.html#index-spider
diff --git a/networking/wget.c b/networking/wget.c
index 6a9604421..93c995205 100644
--- a/networking/wget.c
+++ b/networking/wget.c
@@ -1213,7 +1213,8 @@ static void download_one_url(const char *url)
 				target.path);
 		} else {
 			SENDFMT(sfp, "%s /%s HTTP/1.1\r\n",
-				(option_mask32 & WGET_OPT_POST_DATA) ? "POST" : "GET",
+                    (option_mask32 & WGET_OPT_POST_DATA) ? "POST" :
+					    ((option_mask32 & WGET_OPT_SPIDER) ? "HEAD" : "GET"),
 				target.path);
 		}
 		if (!USR_HEADER_HOST)
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to