]> sjero.net Git - wget/blobdiff - src/retr.c
[svn] Merging fix #20499: MAX_REDIRECTIONS should be configurable.
[wget] / src / retr.c
index 469433ca312eebca16a78df17aeac1f10abced8c..92494fc9722599247966a89faec902ea7cc0e441 100644 (file)
@@ -5,7 +5,7 @@ This file is part of GNU Wget.
 
 GNU Wget is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or (at
+the Free Software Foundation; either version 3 of the License, or (at
 your option) any later version.
 
 GNU Wget is distributed in the hope that it will be useful,
@@ -14,8 +14,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
-along with Wget; if not, write to the Free Software Foundation, Inc.,
-51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+along with Wget.  If not, see <http://www.gnu.org/licenses/>.
 
 In addition, as a special exception, the Free Software Foundation
 gives permission to link the code of its release of Wget with the
@@ -568,12 +567,6 @@ calc_rate (wgint bytes, double secs, int *units)
   return dlrate;
 }
 \f
-/* Maximum number of allowed redirections.  20 was chosen as a
-   "reasonable" value, which is low enough to not cause havoc, yet
-   high enough to guarantee that normal retrievals will not be hurt by
-   the check.  */
-
-#define MAX_REDIRECTIONS 20
 
 #define SUSPEND_POST_DATA do {                 \
   post_data_suspended = true;                  \
@@ -747,10 +740,10 @@ retrieve_url (const char *origurl, char **file, char **newloc,
       mynewloc = xstrdup (newloc_parsed->url);
 
       /* Check for max. number of redirections.  */
-      if (++redirection_count > MAX_REDIRECTIONS)
+      if (++redirection_count > opt.max_redirect)
        {
          logprintf (LOG_NOTQUIET, _("%d redirections exceeded.\n"),
-                    MAX_REDIRECTIONS);
+                    opt.max_redirect);
          url_free (newloc_parsed);
          url_free (u);
          xfree (url);
@@ -844,7 +837,7 @@ retrieve_from_file (const char *file, bool html, int *count)
          break;
        }
       if ((opt.recursive || opt.page_requisites)
-         && (cur_url->url->scheme != SCHEME_FTP || opt.use_proxy))
+         && (cur_url->url->scheme != SCHEME_FTP || getproxy (cur_url->url)))
        {
          int old_follow_ftp = opt.follow_ftp;
 
@@ -1022,6 +1015,20 @@ getproxy (struct url *u)
   return proxy;
 }
 
+/* Returns true if URL would be downloaded through a proxy. */
+
+bool
+url_uses_proxy (const char *url)
+{
+  bool ret;
+  struct url *u = url_parse (url, NULL);
+  if (!u)
+    return false;
+  ret = getproxy (u) != NULL;
+  url_free (u);
+  return ret;
+}
+
 /* Should a host be accessed through proxy, concerning no_proxy?  */
 static bool
 no_proxy_match (const char *host, const char **no_proxy)