summaryrefslogtreecommitdiff
path: root/src/tool_helpers.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/tool_helpers.c')
-rw-r--r--src/tool_helpers.c41
1 files changed, 39 insertions, 2 deletions
diff --git a/src/tool_helpers.c b/src/tool_helpers.c
index 5479a1c0..e264ac79 100644
--- a/src/tool_helpers.c
+++ b/src/tool_helpers.c
@@ -58,6 +58,8 @@ const char *param2text(int res)
return "expected a positive numerical parameter";
case PARAM_LIBCURL_DOESNT_SUPPORT:
return "the installed libcurl version doesn't support this";
+ case PARAM_LIBCURL_UNSUPPORTED_PROTOCOL:
+ return "a specified protocol is unsupported by libcurl";
case PARAM_NO_MEM:
return "out of memory";
default:
@@ -67,13 +69,48 @@ const char *param2text(int res)
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) ||
(*store == req)) {
*store = req;
return 0;
}
-
- warnf(config->global, "You can only select one HTTP request!\n");
+ warnf(config->global, "You can only select one HTTP request method! "
+ "You asked for both %s and %s.\n",
+ reqname[req], reqname[*store]);
return 1;
}
+
+void customrequest_helper(struct OperationConfig *config, HttpReq req,
+ char *method)
+{
+ /* this mirrors the HttpReq enum in tool_sdecls.h */
+ const char *dflt[]= {
+ "GET",
+ "GET",
+ "HEAD",
+ "POST",
+ "POST"
+ };
+
+ if(!method)
+ ;
+ else if(curl_strequal(method, dflt[req])) {
+ notef(config->global, "Unnecessary use of -X or --request, %s is already "
+ "inferred.\n", dflt[req]);
+ }
+ else if(curl_strequal(method, "head")) {
+ warnf(config->global,
+ "Setting custom HTTP method to HEAD may not work the way you "
+ "want.\n");
+ }
+}