aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2000-07-25 07:34:04 +0000
committerDaniel Stenberg <daniel@haxx.se>2000-07-25 07:34:04 +0000
commit6bdfe18b67b0eb300cf7d78e6bfddfea59de0594 (patch)
tree369fb3a1800f4947c16bf9a570020a6ab22cc635 /src
parent78686a548780342ba98ab439bc19ace0abc45cff (diff)
downloadgnurl-6bdfe18b67b0eb300cf7d78e6bfddfea59de0594.tar.gz
gnurl-6bdfe18b67b0eb300cf7d78e6bfddfea59de0594.tar.bz2
gnurl-6bdfe18b67b0eb300cf7d78e6bfddfea59de0594.zip
Added some logic that now prevents multiple conflicting HTTP request types
to get specified with the options.
Diffstat (limited to 'src')
-rw-r--r--src/main.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
index 72fb0504d..9de214c73 100644
--- a/src/main.c
+++ b/src/main.c
@@ -80,6 +80,16 @@
#include <fcntl.h>
#endif
+typedef enum {
+ HTTPREQ_UNSPEC,
+ HTTPREQ_GET,
+ HTTPREQ_HEAD,
+ HTTPREQ_POST,
+ HTTPREQ_SIMPLEPOST,
+ HTTPREQ_CUSTOM,
+ HTTPREQ_LAST
+} HttpReq;
+
/* Just a set of bits */
#define CONF_DEFAULT 0
@@ -186,6 +196,16 @@ void main_free(void)
win32_cleanup();
}
+int SetHTTPrequest(HttpReq req, HttpReq *store)
+{
+ if((*store == HTTPREQ_UNSPEC) ||
+ (*store == req)) {
+ *store = req;
+ return CURLE_OK;
+ }
+ fprintf(stderr, "You can only select one HTTP request!\n");
+ return CURLE_FAILED_INIT;
+}
static void helpf(char *fmt, ...)
{
@@ -313,6 +333,8 @@ struct Configurable {
struct HttpPost *httppost;
struct HttpPost *last_post;
+
+ HttpReq httpreq;
};
static int parseconfig(char *filename,
@@ -610,6 +632,8 @@ static int getparameter(char *flag, /* f or -long-flag */
}
if(config->postfields)
config->conf |= CONF_POST;
+ if(SetHTTPrequest(HTTPREQ_SIMPLEPOST, &config->httpreq))
+ return CURLE_FAILED_INIT;
break;
case 'D':
/* dump-header to given file name */
@@ -650,6 +674,8 @@ static int getparameter(char *flag, /* f or -long-flag */
&config->httppost,
&config->last_post))
return CURLE_FAILED_INIT;
+ if(SetHTTPrequest(HTTPREQ_POST, &config->httpreq))
+ return CURLE_FAILED_INIT;
break;
case 'h': /* h for help */
@@ -665,6 +691,8 @@ static int getparameter(char *flag, /* f or -long-flag */
case 'I':
config->conf ^= CONF_HEADER; /* include the HTTP header in the output */
config->conf ^= CONF_NOBODY; /* don't fetch the body at all */
+ if(SetHTTPrequest(HTTPREQ_HEAD, &config->httpreq))
+ return CURLE_FAILED_INIT;
break;
case 'K':
res = parseconfig(nextarg, config);
@@ -794,6 +822,8 @@ static int getparameter(char *flag, /* f or -long-flag */
case 'X':
/* HTTP request */
GetStr(&config->customrequest, nextarg);
+ if(SetHTTPrequest(HTTPREQ_CUSTOM, &config->httpreq))
+ return CURLE_FAILED_INIT;
break;
case 'y':
/* low speed time */