summaryrefslogtreecommitdiff
path: root/networking/wget.c
diff options
context:
space:
mode:
authorLauri Kasanen2013-12-17 19:03:41 +0100
committerDenys Vlasenko2013-12-17 19:09:43 +0100
commit4967a41ba1d17090e764952975c651b22fd183d1 (patch)
tree1a7b31e0e132639e0dabcfe97541301c47092a91 /networking/wget.c
parent4b26f82c787cf02d600d416159e1a022d278f6f6 (diff)
downloadbusybox-4967a41ba1d17090e764952975c651b22fd183d1.zip
busybox-4967a41ba1d17090e764952975c651b22fd183d1.tar.gz
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 cfbacec..d6c509e 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)
free(h->allocated);
h->allocated = url = xstrdup(src_url);
- if (strncmp(url, "http://", 7) == 0) {
- h->port = bb_lookup_port("http", "tcp", 80);
- h->host = url + 7;
- h->is_ftp = 0;
- } else if (strncmp(url, "ftp://", 6) == 0) {
+ if (strncmp(url, "ftp://", 6) == 0) {
h->port = bb_lookup_port("ftp", "tcp", 21);
h->host = url + 6;
h->is_ftp = 1;
} else
+ if (strncmp(url, "http://", 7) == 0) {
+ h->host = url + 7;
+ http:
+ h->port = bb_lookup_port("http", "tcp", 80);
+ h->is_ftp = 0;
+ } else
+ if (!strstr(url, "//")) {
+ // GNU wget is user-friendly and falls back to http://
+ h->host = url;
+ goto http;
+ } else
bb_error_msg_and_die("not an http or ftp url: %s", sanitize_string(url));
// FYI: