mirror of
https://github.com/moparisthebest/curl
synced 2024-08-13 17:03:50 -04:00
Kevin Roth's comments about -G have been addressed:
o -G -I works on the same command line and makes HEAD instead of GET o -G with an already present question mark in the URL makes an ampersand get added as a separator instead
This commit is contained in:
parent
3aae2ec511
commit
5323340cae
21
src/main.c
21
src/main.c
@ -1654,7 +1654,8 @@ operate(struct Configurable *config, int argc, char *argv[])
|
|||||||
httpgetfields = strdup(config->postfields);
|
httpgetfields = strdup(config->postfields);
|
||||||
free(config->postfields);
|
free(config->postfields);
|
||||||
config->postfields = NULL;
|
config->postfields = NULL;
|
||||||
if(SetHTTPrequest(HTTPREQ_GET, &config->httpreq)) {
|
if(SetHTTPrequest((config->conf&CONF_NOBODY?HTTPREQ_HEAD:HTTPREQ_GET),
|
||||||
|
&config->httpreq)) {
|
||||||
free(httpgetfields);
|
free(httpgetfields);
|
||||||
return PARAM_BAD_USE;
|
return PARAM_BAD_USE;
|
||||||
}
|
}
|
||||||
@ -1858,12 +1859,22 @@ operate(struct Configurable *config, int argc, char *argv[])
|
|||||||
if (httpgetfields) {
|
if (httpgetfields) {
|
||||||
/* Find out whether the url contains a file name */
|
/* Find out whether the url contains a file name */
|
||||||
char *pc =strstr(url, "://");
|
char *pc =strstr(url, "://");
|
||||||
|
char separator='?';
|
||||||
if(pc)
|
if(pc)
|
||||||
pc+=3;
|
pc+=3;
|
||||||
else
|
else
|
||||||
pc=url;
|
pc=url;
|
||||||
pc = strrchr(pc, '/');
|
|
||||||
|
|
||||||
|
pc = strrchr(pc, '/'); /* check for a slash */
|
||||||
|
|
||||||
|
if(pc) {
|
||||||
|
/* there is a slash present in the URL */
|
||||||
|
|
||||||
|
if(strchr(pc, '?'))
|
||||||
|
/* Ouch, there's already a question mark in the URL string, we
|
||||||
|
then appead the data with an amperand separator instead! */
|
||||||
|
separator='&';
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* Then append ? followed by the get fields to the url.
|
* Then append ? followed by the get fields to the url.
|
||||||
*/
|
*/
|
||||||
@ -1872,12 +1883,12 @@ operate(struct Configurable *config, int argc, char *argv[])
|
|||||||
helpf("out of memory\n");
|
helpf("out of memory\n");
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
if (pc)
|
||||||
|
sprintf(urlbuffer, "%s%c%s", url, separator, httpgetfields);
|
||||||
|
else
|
||||||
/* Append / before the ? to create a well-formed url
|
/* Append / before the ? to create a well-formed url
|
||||||
if the url contains a hostname only
|
if the url contains a hostname only
|
||||||
*/
|
*/
|
||||||
if (pc)
|
|
||||||
sprintf(urlbuffer, "%s?%s", url, httpgetfields);
|
|
||||||
else
|
|
||||||
sprintf(urlbuffer, "%s/?%s", url, httpgetfields);
|
sprintf(urlbuffer, "%s/?%s", url, httpgetfields);
|
||||||
|
|
||||||
free(url); /* free previous URL */
|
free(url); /* free previous URL */
|
||||||
|
Loading…
Reference in New Issue
Block a user