aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/fetch/fetch.c
diff options
context:
space:
mode:
authorDag-Erling Smørgrav <des@FreeBSD.org>2000-12-13 11:26:27 +0000
committerDag-Erling Smørgrav <des@FreeBSD.org>2000-12-13 11:26:27 +0000
commit64638f67a7ceaaf07a3ec449a5667690189f9585 (patch)
tree422506ae3bc8317e9c83995389436ce3dde5b5a9 /usr.bin/fetch/fetch.c
parent1ba84976606b34e81005aefcb131d48fe22a1118 (diff)
downloadsrc-64638f67a7ceaaf07a3ec449a5667690189f9585.tar.gz
src-64638f67a7ceaaf07a3ec449a5667690189f9585.zip
If the URL did not specify a scheme, try to guess it from the host name.
Notes
Notes: svn path=/head/; revision=69976
Diffstat (limited to 'usr.bin/fetch/fetch.c')
-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 c24d288659a4..024d71e806d4 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;