curl: add --fail-with-body

Prevent both --fail and --fail-with-body on the same command line.

Verify with test 349, 360 and 361.

Closes #6449
This commit is contained in:
Daniel Stenberg 2021-02-11 08:30:39 +01:00
parent c386a0df44
commit 8a964cb217
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
13 changed files with 179 additions and 14 deletions

View file

@ -280,6 +280,7 @@ static const struct LongShort aliases[]= {
{"fa", "fail-early", ARG_BOOL},
{"fb", "styled-output", ARG_BOOL},
{"fc", "mail-rcpt-allowfails", ARG_BOOL},
{"fd", "fail-with-body", ARG_BOOL},
{"F", "form", ARG_STRING},
{"Fs", "form-string", ARG_STRING},
{"g", "globoff", ARG_BOOL},
@ -1766,8 +1767,17 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
case 'c': /* --mail-rcpt-allowfails */
config->mail_rcpt_allowfails = toggle;
break;
case 'd': /* --fail-with-body */
config->failwithbody = toggle;
break;
default: /* --fail (hard on errors) */
config->failonerror = toggle;
break;
}
if(config->failonerror && config->failwithbody) {
errorf(config->global, "You must select either --fail or "
"--fail-with-body, not both.\n");
return PARAM_BAD_USE;
}
break;
case 'F':