From ff81ecaf180fd3309e5836ebe13e42396b6599fb Mon Sep 17 00:00:00 2001 From: ethus3h Date: Sun, 10 Jun 2018 23:23:09 -0400 Subject: [PATCH] Add option to retry on host errors --- doc/wget.texi | 4 ++++ src/http.c | 13 ++++++++++++- src/init.c | 1 + src/main.c | 1 + src/options.h | 1 + 5 files changed, 19 insertions(+), 1 deletion(-) diff --git a/doc/wget.texi b/doc/wget.texi index eaf6b380..38b4a245 100644 --- a/doc/wget.texi +++ b/doc/wget.texi @@ -1750,6 +1750,10 @@ 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-on-host-error +Consider host errors, such as ``Temporary failure in name resolution'', +as non-fatal, transient errors. + @item address@hidden,code,...]} Consider given HTTP response codes as non-fatal, transient errors. Supply a comma-separated list of 3-digit HTTP response codes as diff --git a/src/http.c b/src/http.c index 77bdbbed..bb52218f 100644 --- a/src/http.c +++ b/src/http.c @@ -4386,7 +4386,18 @@ http_loop (const struct url *u, struct url *original_url, char **newloc, logputs (LOG_VERBOSE, "\n"); logprintf (LOG_NOTQUIET, _("Cannot write to %s (%s).\n"), quote (hstat.local_file), strerror (errno)); - case HOSTERR: case CONIMPOSSIBLE: case PROXERR: case SSLINITFAILED: + case HOSTERR: + /* Fatal unless option set otherwise. */ + if ( opt.retry_on_host_error ) + { + printwhat (count, opt.ntry); + xfree (hstat.message); + xfree (hstat.error); + continue; + } + ret = err; + goto exit; + case CONIMPOSSIBLE: case PROXERR: case SSLINITFAILED: case CONTNOTSUPPORTED: case VERIFCERTERR: case FILEBADFILE: case UNKNOWNATTR: /* Fatal errors just return from the function. */ diff --git a/src/init.c b/src/init.c index eb81ab47..bb82b329 100644 --- a/src/init.c +++ b/src/init.c @@ -313,6 +313,7 @@ static const struct { { "restrictfilenames", NULL, cmd_spec_restrict_file_names }, { "retrsymlinks", &opt.retr_symlinks, cmd_boolean }, { "retryconnrefused", &opt.retry_connrefused, cmd_boolean }, + { "retryonhosterror", &opt.retry_on_host_error, cmd_boolean }, { "retryonhttperror", &opt.retry_on_http_error, cmd_string }, { "robots", &opt.use_robots, cmd_boolean }, { "savecookies", &opt.cookies_output, cmd_file }, diff --git a/src/main.c b/src/main.c index 73b7baee..e731f3aa 100644 --- a/src/main.c +++ b/src/main.c @@ -420,6 +420,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-on-host-error", 0, OPT_BOOLEAN, "retryonhosterror", -1 }, { "retry-on-http-error", 0, OPT_VALUE, "retryonhttperror", -1 }, { "save-cookies", 0, OPT_VALUE, "savecookies", -1 }, { "save-headers", 0, OPT_BOOLEAN, "saveheaders", -1 }, diff --git a/src/options.h b/src/options.h index cf4dec88..19d93f14 100644 --- a/src/options.h +++ b/src/options.h @@ -41,6 +41,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_on_host_error; /* Treat host errors as non-fatal. */ char *retry_on_http_error; /* Treat given HTTP errors as non-fatal. */ bool background; /* Whether we should work in background. */ bool ignore_length; /* Do we heed content-length at all? */ -- 2.16.1