aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2001-08-19 17:09:06 +0000
committerDaniel Stenberg <daniel@haxx.se>2001-08-19 17:09:06 +0000
commit90270054115e00a49e0fdfbed406ae23cceac198 (patch)
tree233c136bbe0b7d4131025fde154226fa8126fbc4
parent1d3542a38f87af0f9bafbe8c4373a33a81556822 (diff)
SM's fix for -G on URLs with host name only
-rw-r--r--src/main.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/main.c b/src/main.c
index 948bfab0d..0e82748cc 100644
--- a/src/main.c
+++ b/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! */
}