Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "tool_setup.h"
00023
00024 #include "strcase.h"
00025
00026 #define ENABLE_CURLX_PRINTF
00027
00028 #include "curlx.h"
00029
00030 #include "tool_cfgable.h"
00031 #include "tool_msgs.h"
00032 #include "tool_getparam.h"
00033 #include "tool_helpers.h"
00034
00035 #include "memdebug.h"
00036
00037
00038
00039
00040
00041 const char *param2text(int res)
00042 {
00043 ParameterError error = (ParameterError)res;
00044 switch(error) {
00045 case PARAM_GOT_EXTRA_PARAMETER:
00046 return "had unsupported trailing garbage";
00047 case PARAM_OPTION_UNKNOWN:
00048 return "is unknown";
00049 case PARAM_OPTION_AMBIGUOUS:
00050 return "is ambiguous";
00051 case PARAM_REQUIRES_PARAMETER:
00052 return "requires parameter";
00053 case PARAM_BAD_USE:
00054 return "is badly used here";
00055 case PARAM_BAD_NUMERIC:
00056 return "expected a proper numerical parameter";
00057 case PARAM_NEGATIVE_NUMERIC:
00058 return "expected a positive numerical parameter";
00059 case PARAM_LIBCURL_DOESNT_SUPPORT:
00060 return "the installed libcurl version doesn't support this";
00061 case PARAM_LIBCURL_UNSUPPORTED_PROTOCOL:
00062 return "a specified protocol is unsupported by libcurl";
00063 case PARAM_NO_MEM:
00064 return "out of memory";
00065 default:
00066 return "unknown error";
00067 }
00068 }
00069
00070 int SetHTTPrequest(struct OperationConfig *config, HttpReq req, HttpReq *store)
00071 {
00072
00073 const char *reqname[]= {
00074 "",
00075 "GET (-G, --get)",
00076 "HEAD (-I, --head)",
00077 "multipart formpost (-F, --form)",
00078 "POST (-d, --data)"
00079 };
00080
00081 if((*store == HTTPREQ_UNSPEC) ||
00082 (*store == req)) {
00083 *store = req;
00084 return 0;
00085 }
00086 warnf(config->global, "You can only select one HTTP request method! "
00087 "You asked for both %s and %s.\n",
00088 reqname[req], reqname[*store]);
00089
00090 return 1;
00091 }
00092
00093 void customrequest_helper(struct OperationConfig *config, HttpReq req,
00094 char *method)
00095 {
00096
00097 const char *dflt[]= {
00098 "GET",
00099 "GET",
00100 "HEAD",
00101 "POST",
00102 "POST"
00103 };
00104
00105 if(!method)
00106 ;
00107 else if(curl_strequal(method, dflt[req])) {
00108 notef(config->global, "Unnecessary use of -X or --request, %s is already "
00109 "inferred.\n", dflt[req]);
00110 }
00111 else if(curl_strequal(method, "head")) {
00112 warnf(config->global,
00113 "Setting custom HTTP method to HEAD with -X/--request may not work "
00114 "the way you want. Consider using -I/--head instead.\n");
00115 }
00116 }