-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
--retry-all-errors doesn't retry 400 status code #6712
Comments
HTTP status code errors (4xx,5xx) are not transfer errors so curl won't error unless you use --fail. That may need more presence in the documentation but I don't know where. 4.4 Why do I get downloaded data even though the web page doesn't exist? |
Makes sense to me, could be good to call this out in the man page under I've put some possible changes in bold.
|
- Add a paragraph explaining that curl does not consider HTTP response errors as curl errors, and how that behavior can be modified by using --retry and --fail. The --retry-all-errors doc says "Retry on any error" which some users may find misleading without the added explanation. Ref: https://curl.se/docs/faq.html#Why_do_I_get_downloaded_data_eve Ref: https://curl.se/docs/faq.html#curl_doesn_t_return_error_for_HT Reported-by: Lawrence Gripper Fixes curl#6712 Closes #xxxx
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). |
Looks great, thanks! |
First up, thanks for curl it's awesome!
I did this
curl "https://ense241pboy9vso.m.pipedream.net" --retry 5 --retry-all-errors -X POST -v
The endpoint returns a
400
status code with a body ofhello 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 sayI 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 whenretry-all-errors
is set.I think this is becauseReading the code again I think this was way off.--fail
is causing thisif
to hit and the 400 to be counted as an error.New theory, I think to retry 400 response codes with
retry-all-errors
the following lines need tweaking (never played with C so apologies if I'm way off again).curl/src/tool_operate.c
Lines 373 to 384 in 40f3c18
Maybe to be
else if(config->failwithbody || config->retry_all_errors ) {
I've never played in C but happy to have a go at this tweak and adding a test case for it.
curl/libcurl version
operating system
Tested in debian sid docker container.
The text was updated successfully, but these errors were encountered: