Assume HTTP if no protocol is specified

This commit is contained in:
pooler 2012-03-06 00:10:35 +01:00
parent f073f8ed58
commit 8625cf40f6

View file

@ -769,20 +769,28 @@ static void parse_arg (int key, char *arg)
rpc_user = strdup(arg);
break;
case 'o': /* --url */
if (strncmp(arg, "http://", 7) &&
strncmp(arg, "https://", 8))
p = strstr(arg, "://");
if (p) {
if (strncmp(arg, "http://", 7) && strncmp(arg, "https://", 8))
show_usage_and_exit(1);
free(rpc_url);
rpc_url = strdup(arg);
} else {
if (!strlen(arg) || *arg == '/')
show_usage_and_exit(1);
free(rpc_url);
rpc_url = malloc((strlen(arg) + 8) * sizeof(char));
sprintf(rpc_url, "http://%s", arg);
}
p = strchr(rpc_url, '@');
if (p) {
char *ap = strstr(rpc_url, "//") + 2;
char *ap = strstr(rpc_url, "://") + 3;
*p = '\0';
if (!strchr(ap, ':'))
show_usage_and_exit(1);
free(rpc_userpass);
rpc_userpass = strdup(ap);
strcpy(ap, p + 1);
memmove(ap, p + 1, (strlen(p + 1) + 1) * sizeof(char));
}
break;
case 'O': /* --userpass */