aboutsummaryrefslogtreecommitdiff
path: root/networking/wget.c
diff options
context:
space:
mode:
authorLauri Kasanen <curaga@operamail.com>2013-12-17 19:03:41 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2013-12-17 19:09:43 +0100
commit4967a41ba1d17090e764952975c651b22fd183d1 (patch)
tree1a7b31e0e132639e0dabcfe97541301c47092a91 /networking/wget.c
parent4b26f82c787cf02d600d416159e1a022d278f6f6 (diff)
downloadbusybox-w32-4967a41ba1d17090e764952975c651b22fd183d1.tar.gz
busybox-w32-4967a41ba1d17090e764952975c651b22fd183d1.tar.bz2
busybox-w32-4967a41ba1d17090e764952975c651b22fd183d1.zip
wget: user-friendly fallback to http
GNU wget: wget google.com // ok bb before: wget google.com // wget: not an http or ftp url function old new delta parse_url 317 339 +22 Signed-off-by: Lauri Kasanen <curaga@operamail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/wget.c')
-rw-r--r--networking/wget.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/networking/wget.c b/networking/wget.c
index cfbaceced..d6c509edc 100644
--- a/networking/wget.c
+++ b/networking/wget.c
@@ -274,15 +274,22 @@ static void parse_url(const char *src_url, struct host_info *h)
274 free(h->allocated); 274 free(h->allocated);
275 h->allocated = url = xstrdup(src_url); 275 h->allocated = url = xstrdup(src_url);
276 276
277 if (strncmp(url, "http://", 7) == 0) { 277 if (strncmp(url, "ftp://", 6) == 0) {
278 h->port = bb_lookup_port("http", "tcp", 80);
279 h->host = url + 7;
280 h->is_ftp = 0;
281 } else if (strncmp(url, "ftp://", 6) == 0) {
282 h->port = bb_lookup_port("ftp", "tcp", 21); 278 h->port = bb_lookup_port("ftp", "tcp", 21);
283 h->host = url + 6; 279 h->host = url + 6;
284 h->is_ftp = 1; 280 h->is_ftp = 1;
285 } else 281 } else
282 if (strncmp(url, "http://", 7) == 0) {
283 h->host = url + 7;
284 http:
285 h->port = bb_lookup_port("http", "tcp", 80);
286 h->is_ftp = 0;
287 } else
288 if (!strstr(url, "//")) {
289 // GNU wget is user-friendly and falls back to http://
290 h->host = url;
291 goto http;
292 } else
286 bb_error_msg_and_die("not an http or ftp url: %s", sanitize_string(url)); 293 bb_error_msg_and_die("not an http or ftp url: %s", sanitize_string(url));
287 294
288 // FYI: 295 // FYI: