curl "https://ense241pboy9vso.m.pipedream.net" --retry 5 --retry-all-errors -X POST -v
The endpoint returns a 400 status code with a body of hello world.
curl doesn't retry the request and returns the body.
After reading through the code I discovered that by adding --fail to the command I could get the behaviour that I wanted. curl "https://ense241pboy9vso.m.pipedream.net" --retry 5 --retry-all-errors -X POST --fail will retry the 400 response.
I expected the following
I expected the 400 response to be retried.
Given the --retry-all-errors docs say
Retry on any error. This option is used together with --retry.
I think either a note in the docs for retry-all-errors to highlight that --fail is needed to retry http error codes or tweaks to the source so any http error code is retried when retry-all-errors is set.
Makes sense to me, could be good to call this out in the man page under --retry-all-errors. The wording around any error in the existing doc is what has threw me.
I've put some possible changes in bold.
Retry on any transfer error. This option is used together with --retry.
This option is the "sledgehammer" of retrying. Do not use this option by default (eg in curlrc), there may be unintended consequences such as sending or receiving duplicate data. Do not use with redirected input or output. You'd be much better off handling your unique problems in shell script. Note that HTTP Status code errors are not retried by default add --fail to ensure these are retried as well. Please read the example below.
I've proposed #6720 to fix this, please take a look. I've made a distinction between --retry (which will retry some HTTP response codes that indicate transient HTTP errors) and --fail (which does almost all 4xx and 5xx).