aria2 / aria2

aria2 is a lightweight multi-protocol & multi-source, cross platform download utility operated in command-line. It supports HTTP/HTTPS, FTP, SFTP, BitTorrent and Metalink.
https://aria2.github.io/
GNU General Public License v2.0
35.22k stars 3.57k forks source link

No retry after HTTP Error 520 or 521 #1229

Open carp3 opened 6 years ago

carp3 commented 6 years ago

cloud-flare uses http error 520 and 521 when web server is not responding/over loaded. but aria abort download and doesn't retry

aria2c --max-tries=0 --max-file-not-found=10 https://httpstat.us/520

Output:

D:\>aria2c  --max-tries=0  --max-file-not-found=10 https://httpstat.us/520

06/30 23:09:54 [NOTICE] Downloading 1 item(s)
[#a72423 0B/0B CN:1 DL:0B]
06/30 23:09:57 [ERROR] CUID#7 - Download aborted. URI=https://httpstat.us/520
Exception: [AbstractCommand.cc:351] errorCode=22 URI=https://httpstat.us/520
  -> [HttpSkipResponseCommand.cc:240] errorCode=22 The response status is not successful. status=520

06/30 23:09:57 [NOTICE] Download GID#a72423ea1abda35a not complete:

Download Results:
gid   |stat|avg speed  |path/URI
======+====+===========+=======================================================
a72423|ERR |       0B/s|https://httpstat.us/520

Status Legend:
(ERR):error occurred.

aria2 will resume download if the transfer is restarted.
If there are any errors, then see the log file. See '-l' option in help/man page for details.
myfreeer commented 6 years ago

Apply this patch and rebuild aria2.

diff --git a/src/HttpSkipResponseCommand.cc b/src/HttpSkipResponseCommand.cc
index a722d77..1446678 100644
--- a/src/HttpSkipResponseCommand.cc
+++ b/src/HttpSkipResponseCommand.cc
@@ -222,6 +222,8 @@ bool HttpSkipResponseCommand::processResponse()
                          error_code::RESOURCE_NOT_FOUND);
     case 502:
     case 503:
+    case 520:
+    case 521:
       // Only retry if pretry-wait > 0. Hammering 'busy' server is not
       // a good idea.
       if (getOption()->getAsInt(PREF_RETRY_WAIT) > 0) {