curl: point out the conflicting HTTP methods if used

It isn't always clear to the user which options that cause the HTTP
methods to conflict so by spelling them out it should hopefully be
easier to understand why curl complains.
This commit is contained in:
Daniel Stenberg 2015-08-25 09:20:56 +02:00
parent ce034356d2
commit 4a889441d3
4 changed files with 16 additions and 8 deletions

View File

@ -1422,7 +1422,7 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
&config->last_post, &config->last_post,
(subletter=='s')?TRUE:FALSE)) /* 's' means literal string */ (subletter=='s')?TRUE:FALSE)) /* 's' means literal string */
return PARAM_BAD_USE; return PARAM_BAD_USE;
if(SetHTTPrequest(config, HTTPREQ_POST, &config->httpreq)) if(SetHTTPrequest(config, HTTPREQ_FORMPOST, &config->httpreq))
return PARAM_BAD_USE; return PARAM_BAD_USE;
break; break;

View File

@ -69,13 +69,23 @@ const char *param2text(int res)
int SetHTTPrequest(struct OperationConfig *config, HttpReq req, HttpReq *store) int SetHTTPrequest(struct OperationConfig *config, HttpReq req, HttpReq *store)
{ {
/* this mirrors the HttpReq enum in tool_sdecls.h */
const char *reqname[]= {
"", /* unspec */
"GET (-G, --get)",
"HEAD (-I, --head)",
"multipart formpost (-F, --form)",
"POST (-d, --data)"
};
if((*store == HTTPREQ_UNSPEC) || if((*store == HTTPREQ_UNSPEC) ||
(*store == req)) { (*store == req)) {
*store = req; *store = req;
return 0; return 0;
} }
warnf(config->global, "You can only select one HTTP request method! "
warnf(config->global, "You can only select one HTTP request method!\n"); "You asked for both %s and %s.\n",
reqname[req], reqname[*store]);
return 1; return 1;
} }

View File

@ -935,7 +935,7 @@ static CURLcode operate_do(struct GlobalConfig *global,
my_setopt(curl, CURLOPT_POSTFIELDSIZE_LARGE, my_setopt(curl, CURLOPT_POSTFIELDSIZE_LARGE,
config->postfieldsize); config->postfieldsize);
break; break;
case HTTPREQ_POST: case HTTPREQ_FORMPOST:
my_setopt_httppost(curl, CURLOPT_HTTPPOST, config->httppost); my_setopt_httppost(curl, CURLOPT_HTTPPOST, config->httppost);
break; break;
default: default:

View File

@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -135,10 +135,8 @@ typedef enum {
HTTPREQ_UNSPEC, /* first in list */ HTTPREQ_UNSPEC, /* first in list */
HTTPREQ_GET, HTTPREQ_GET,
HTTPREQ_HEAD, HTTPREQ_HEAD,
HTTPREQ_POST, HTTPREQ_FORMPOST,
HTTPREQ_SIMPLEPOST, HTTPREQ_SIMPLEPOST,
HTTPREQ_CUSTOM,
HTTPREQ_LAST /* last in list */
} HttpReq; } HttpReq;