summaryrefslogtreecommitdiffstats
path: root/usr.bin/fetch
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2000-12-13 11:26:27 +0000
committerdes <des@FreeBSD.org>2000-12-13 11:26:27 +0000
commit5612c73391b08c6b3a883c7a470f44bc51e40ef3 (patch)
treea59a7ac2a6723ec0d2f2fe58077b391b443df072 /usr.bin/fetch
parentae0af0d011fe1231b7c46f671bec0ebf92af084d (diff)
downloadFreeBSD-src-5612c73391b08c6b3a883c7a470f44bc51e40ef3.zip
FreeBSD-src-5612c73391b08c6b3a883c7a470f44bc51e40ef3.tar.gz
If the URL did not specify a scheme, try to guess it from the host name.
Diffstat (limited to 'usr.bin/fetch')
-rw-r--r--usr.bin/fetch/fetch.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/usr.bin/fetch/fetch.c b/usr.bin/fetch/fetch.c
index c24d288..024d71e 100644
--- a/usr.bin/fetch/fetch.c
+++ b/usr.bin/fetch/fetch.c
@@ -197,6 +197,16 @@ fetch(char *URL, char *path)
goto failure;
}
+ /* if no scheme was specified, take a guess */
+ if (!*url->scheme) {
+ if (!*url->host)
+ strcpy(url->scheme, SCHEME_FILE);
+ else if (strncasecmp(url->host, "ftp.", 4))
+ strcpy(url->scheme, SCHEME_FTP);
+ else if (strncasecmp(url->host, "www.", 4))
+ strcpy(url->scheme, SCHEME_HTTP);
+ }
+
timeout = 0;
*flags = 0;
count = 0;
OpenPOWER on IntegriCloud