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); rpc_user = strdup(arg);
break; break;
case 'o': /* --url */ case 'o': /* --url */
if (strncmp(arg, "http://", 7) && p = strstr(arg, "://");
strncmp(arg, "https://", 8)) if (p) {
if (strncmp(arg, "http://", 7) && strncmp(arg, "https://", 8))
show_usage_and_exit(1); show_usage_and_exit(1);
free(rpc_url); free(rpc_url);
rpc_url = strdup(arg); 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, '@'); p = strchr(rpc_url, '@');
if (p) { if (p) {
char *ap = strstr(rpc_url, "//") + 2; char *ap = strstr(rpc_url, "://") + 3;
*p = '\0'; *p = '\0';
if (!strchr(ap, ':')) if (!strchr(ap, ':'))
show_usage_and_exit(1); show_usage_and_exit(1);
free(rpc_userpass); free(rpc_userpass);
rpc_userpass = strdup(ap); rpc_userpass = strdup(ap);
strcpy(ap, p + 1); memmove(ap, p + 1, (strlen(p + 1) + 1) * sizeof(char));
} }
break; break;
case 'O': /* --userpass */ case 'O': /* --userpass */