bug-wget
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-wget] [PATCH] Add support for --retry-http503


From: Tom Szilagyi
Subject: [Bug-wget] [PATCH] Add support for --retry-http503
Date: Sun, 29 Jan 2017 22:20:04 +0100
User-agent: Mutt/1.5.23 (2014-03-12)

Consider HTTP 503 (Service unavailable) as a non-fatal, transient
error. Normally Wget gives up immediately on receiving this HTTP
response. Certain special use cases might require Wget to retry even
in the face of this error. With this option, such retries are
performed subject to the normal retry timing and retry count
limitations of Wget. Using this option is generally not recommended.

Tested manually by pointing wget to http://httpbin.org/status/503
with and without supplying the --retry-http503 option.

This takes care of http://savannah.gnu.org/bugs/?20417
---
 doc/wget.texi | 8 ++++++++
 src/http.c    | 5 +++++
 src/init.c    | 1 +
 src/main.c    | 1 +
 src/options.h | 1 +
 5 files changed, 16 insertions(+)

diff --git a/doc/wget.texi b/doc/wget.texi
index f42773e..6700dc2 100644
--- a/doc/wget.texi
+++ b/doc/wget.texi
@@ -1716,6 +1716,14 @@ some few obscure servers, which never send HTTP 
authentication
 challenges, but accept unsolicited auth info, say, in addition to
 form-based authentication.
 
address@hidden --retry-http503
+Consider HTTP 503 (Service unavailable) as a non-fatal, transient
+error. Normally Wget gives up immediately on receiving this HTTP
+response. Certain special use cases might require Wget to retry even
+in the face of this error. With this option, such retries are
+performed subject to the normal retry timing and retry count
+limitations of Wget. Using this option is generally not recommended.
+
 @end table
 
 @node HTTPS (SSL/TLS) Options, FTP Options, HTTP Options, Invoking
diff --git a/src/http.c b/src/http.c
index 9f03d86..0a32126 100644
--- a/src/http.c
+++ b/src/http.c
@@ -4319,6 +4319,11 @@ http_loop (const struct url *u, struct url 
*original_url, char **newloc,
               logprintf (LOG_NOTQUIET, _("\
 Remote file does not exist -- broken link!!!\n"));
             }
+          else if (opt.retry_http503 &&
+                   hstat.statcode == HTTP_STATUS_UNAVAILABLE)
+            {
+              continue;
+            }
           else
             {
               logprintf (LOG_NOTQUIET, _("%s ERROR %d: %s.\n"),
diff --git a/src/init.c b/src/init.c
index 271bc77..bbb6473 100644
--- a/src/init.c
+++ b/src/init.c
@@ -304,6 +304,7 @@ static const struct {
   { "restrictfilenames", NULL,                  cmd_spec_restrict_file_names },
   { "retrsymlinks",     &opt.retr_symlinks,     cmd_boolean },
   { "retryconnrefused", &opt.retry_connrefused, cmd_boolean },
+  { "retryhttp503",     &opt.retry_http503,     cmd_boolean },
   { "robots",           &opt.use_robots,        cmd_boolean },
   { "savecookies",      &opt.cookies_output,    cmd_file },
   { "saveheaders",      &opt.save_headers,      cmd_boolean },
diff --git a/src/main.c b/src/main.c
index e393597..b160a9f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -404,6 +404,7 @@ static struct cmdline_option option_data[] =
     { "restrict-file-names", 0, OPT_BOOLEAN, "restrictfilenames", -1 },
     { "retr-symlinks", 0, OPT_BOOLEAN, "retrsymlinks", -1 },
     { "retry-connrefused", 0, OPT_BOOLEAN, "retryconnrefused", -1 },
+    { "retry-http503", 0, OPT_BOOLEAN, "retryhttp503", -1 },
     { "save-cookies", 0, OPT_VALUE, "savecookies", -1 },
     { "save-headers", 0, OPT_BOOLEAN, "saveheaders", -1 },
     { IF_SSL ("secure-protocol"), 0, OPT_VALUE, "secureprotocol", -1 },
diff --git a/src/options.h b/src/options.h
index d713acc..d42dc30 100644
--- a/src/options.h
+++ b/src/options.h
@@ -43,6 +43,7 @@ struct options
   bool quiet;                   /* Are we quiet? */
   int ntry;                     /* Number of tries per URL */
   bool retry_connrefused;       /* Treat CONNREFUSED as non-fatal. */
+  bool retry_http503;           /* Treat HTTP 503 errors as non-fatal. */
   bool background;              /* Whether we should work in background. */
   bool ignore_length;           /* Do we heed content-length at all?  */
   bool recursive;               /* Are we recursive? */
-- 
2.1.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]