mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 23:58:49 -05:00
SM's fix for -G on URLs with host name only
This commit is contained in:
parent
1d3542a38f
commit
9027005411
25
src/main.c
25
src/main.c
@ -314,10 +314,10 @@ static void help(void)
|
||||
" -f/--fail Fail silently (no output at all) on errors (H)\n"
|
||||
" -F/--form <name=content> Specify HTTP POST data (H)\n"
|
||||
" -g/--globoff Disable URL sequences and ranges using {} and []\n"
|
||||
" -G/--get HTTP GET(H)\n"
|
||||
" -h/--help This help text\n"
|
||||
" -H/--header <line> Custom header to pass to server. (H)");
|
||||
puts(" -i/--include Include the HTTP-header in the output (H)\n"
|
||||
" -G/--get Send the -d data with a HTTP GET (H)\n");
|
||||
puts(" -h/--help This help text\n"
|
||||
" -H/--header <line> Custom header to pass to server. (H)"
|
||||
" -i/--include Include the HTTP-header in the output (H)\n"
|
||||
" -I/--head Fetch document info only (HTTP HEAD/FTP SIZE)\n"
|
||||
" --interface <interface> Specify the interface to be used\n"
|
||||
" --krb4 <level> Enable krb4 with specified security level (F)\n"
|
||||
@ -1856,6 +1856,14 @@ operate(struct Configurable *config, int argc, char *argv[])
|
||||
printf("%s%s\n", CURLseparator, url);
|
||||
}
|
||||
if (httpgetfields) {
|
||||
/* Find out whether the url contains a file name */
|
||||
char *pc =strstr(url, "://");
|
||||
if(pc)
|
||||
pc+=3;
|
||||
else
|
||||
pc=url;
|
||||
pc = strrchr(pc, '/');
|
||||
|
||||
/*
|
||||
* Then append ? followed by the get fields to the url.
|
||||
*/
|
||||
@ -1864,7 +1872,14 @@ operate(struct Configurable *config, int argc, char *argv[])
|
||||
helpf("out of memory\n");
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
}
|
||||
sprintf(urlbuffer, "%s?%s", url, httpgetfields);
|
||||
/* Append / before the ? to create a well-formed url
|
||||
if the url contains a hostname only
|
||||
*/
|
||||
if (pc)
|
||||
sprintf(urlbuffer, "%s?%s", url, httpgetfields);
|
||||
else
|
||||
sprintf(urlbuffer, "%s/?%s", url, httpgetfields);
|
||||
|
||||
free(url); /* free previous URL */
|
||||
url = urlbuffer; /* use our new URL instead! */
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user