if(result)
return result;
- my_setopt_long(curl, CURLOPT_FAILONERROR, config->failonerror);
+ my_setopt_long(curl, CURLOPT_FAILONERROR, config->fail == FAIL_WO_BODY);
my_setopt_str(curl, CURLOPT_REQUEST_TARGET, config->request_target);
my_setopt_long(curl, CURLOPT_UPLOAD, !!per->uploadfile);
my_setopt_long(curl, CURLOPT_DIRLISTONLY, config->dirlistonly);
curl_off_t urlidx; /* index for globbed URLs */
};
+#define FAIL_NONE 0
+#define FAIL_WITH_BODY 1
+#define FAIL_WO_BODY 2
+
struct OperationConfig {
struct dynbuf postdata;
char *useragent;
unsigned short porttouse;
unsigned char ssl_version; /* 0 - 4, 0 being default */
unsigned char ssl_version_max; /* 0 - 4, 0 being default */
+ unsigned char fail; /* NONE, with body, without body */
BIT(remote_name_all); /* --remote-name-all */
BIT(remote_time);
BIT(cookiesession); /* new session? */
BIT(ftp_append); /* APPE on ftp */
BIT(use_ascii); /* select ASCII or text transfer */
BIT(autoreferer); /* automatically set referer */
- BIT(failonerror); /* fail on (HTTP) errors */
- BIT(failwithbody); /* fail on (HTTP) errors but still store body */
BIT(show_headers); /* show headers to data output */
BIT(no_body); /* do not get the body */
BIT(dirlistonly); /* only get the FTP dir list */
case C_MAIL_RCPT_ALLOWFAILS: /* --mail-rcpt-allowfails */
config->mail_rcpt_allowfails = toggle;
break;
- case C_FAIL_WITH_BODY: /* --fail-with-body */
- config->failwithbody = toggle;
- if(config->failonerror && config->failwithbody) {
- errorf("You must select either --fail or "
- "--fail-with-body, not both.");
- return PARAM_BAD_USE;
- }
- break;
case C_REMOVE_ON_ERROR: /* --remove-on-error */
if(config->use_resume && toggle) {
errorf("--continue-at is mutually exclusive with --remove-on-error");
}
config->rm_partial = toggle;
break;
- case C_FAIL: /* --fail */
- config->failonerror = toggle;
- if(config->failonerror && config->failwithbody) {
- errorf("You must select either --fail or "
- "--fail-with-body, not both.");
- return PARAM_BAD_USE;
- }
+ case C_FAIL: /* --fail without body */
+ if(toggle && (config->fail == FAIL_WITH_BODY))
+ warnf("--fail deselects --fail-with-body here");
+ config->fail = toggle ? FAIL_WO_BODY : FAIL_NONE;
+ break;
+ case C_FAIL_WITH_BODY: /* --fail-with-body */
+ if(toggle && (config->fail == FAIL_WO_BODY))
+ warnf("--fail-with-body deselects --fail here");
+ config->fail = toggle ? FAIL_WITH_BODY : FAIL_NONE;
break;
case C_GLOBOFF: /* --globoff */
config->globoff = toggle;
retry = RETRY_CONNREFUSED;
}
else if((CURLE_OK == result) ||
- ((config->failonerror || config->failwithbody) &&
- (CURLE_HTTP_RETURNED_ERROR == result))) {
+ (config->fail && (CURLE_HTTP_RETURNED_ERROR == result))) {
/* If it returned OK. _or_ failonerror was enabled and it
returned due to such an error, check for HTTP transient
errors to retry on. */
if(result == CURLE_PEER_FAILED_VERIFICATION)
fputs(CURL_CA_CERT_ERRORMSG, tool_stderr);
}
- else if(config->failwithbody) {
+ else if(config->fail == FAIL_WITH_BODY) {
/* if HTTP response >= 400, return error */
long code = 0;
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &code);
</keywords>
</info>
-# Client-side
+<reply>
+<data crlf="yes">
+HTTP/1.1 200 OK
+Date: Tue, 09 Nov 2010 14:49:00 GMT
+Server: test-server/fake
+Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT
+ETag: "21025-dc7-39462498"
+Accept-Ranges: bytes
+Content-Length: 6
+Connection: close
+Content-Type: text/html
+Funny-head: yesyes
+
+-foo-
+</data>
+</reply>
+
<client>
<server>
http
Error on both --fail-with-body and --fail
</name>
<command>
-http://%HOSTIP:%HTTPPORT/%TESTNUMBER --fail-with-body --fail
+http://%HOSTIP:%HTTPPORT/%TESTNUMBER --fail-with-body --fail --no-progress-meter
</command>
</client>
# Verify data after the test has been "shot"
<verify>
-<errorcode>
-2
-</errorcode>
+<stderr mode="text">
+Warning: --fail deselects --fail-with-body here
+</stderr>
</verify>
</testcase>