]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tool_operate: retry on HTTP response codes 522 and 524
authorJay Satiro <raysatiro@yahoo.com>
Fri, 10 Oct 2025 19:42:27 +0000 (15:42 -0400)
committerJay Satiro <raysatiro@yahoo.com>
Tue, 14 Oct 2025 15:06:24 +0000 (11:06 -0400)
- Treat HTTP response codes 522 and 524 as a transient error since
  Cloudflare may use them instead of 504 to signal timeout.

For example here is a 522 error message from Cloudflare:

"The initial connection between Cloudflare's network and the origin web
server timed out. As a result, the web page can not be displayed."

Prior to this change the curl tool did not retry on HTTP response codes
522 and 524 when --retry was used.

Fixes https://github.com/curl/curl/discussions/16143
Closes https://github.com/curl/curl/pull/19011

docs/cmdline-opts/retry.md
src/tool_operate.c

index f55d8edcca12f89577cd215113e96ffc18907485..4d9e83cd5f404087023f23a7b202c72a00c2f154 100644 (file)
@@ -20,8 +20,8 @@ Example:
 If a transient error is returned when curl tries to perform a transfer, it
 retries this number of times before giving up. Setting the number to 0 makes
 curl do no retries (which is the default). Transient error means either: a
-timeout, an FTP 4xx response code or an HTTP 408, 429, 500, 502, 503 or 504
-response code.
+timeout, an FTP 4xx response code or an HTTP 408, 429, 500, 502, 503, 504, 522
+or 524 response code.
 
 When curl is about to retry a transfer, it first waits one second and then for
 all forthcoming retries it doubles the waiting time until it reaches 10
index 397b2159e198a7800ef26e0b6a50d44d7b435d8f..c7d01bb59af22930205b657f61c7001a0066b99c 100644 (file)
@@ -412,6 +412,8 @@ static CURLcode retrycheck(struct OperationConfig *config,
       case 502: /* Bad Gateway */
       case 503: /* Service Unavailable */
       case 504: /* Gateway Timeout */
+      case 522: /* Connection Timed Out (Cloudflare) */
+      case 524: /* Proxy Read Timeout (Cloudflare) */
         retry = RETRY_HTTP;
         /*
          * At this point, we have already written data to the output