Keith Moore wrote:

> In that case, "--no-redirections" makes much more sense.

I've attached the "--no-redirections" version of the patch.


KM
diff -uprN -x .svn wget.orig/doc/ChangeLog wget/doc/ChangeLog
--- wget.orig/doc/ChangeLog     2005-11-25 14:01:03.500000000 -0600
+++ wget/doc/ChangeLog  2005-11-25 23:37:56.569037300 -0600
@@ -1,3 +1,9 @@
+2005-11-25  Keith Moore  <[EMAIL PROTECTED]>
+
+       * sample.wgetrc: Added redirections switch.
+
+       * wget.texi: Document redirections switch.
+
 2005-11-15  Hrvoje Niksic  <[EMAIL PROTECTED]>
 
        * wget.texi: Document https_proxy.
diff -uprN -x .svn wget.orig/doc/sample.wgetrc wget/doc/sample.wgetrc
--- wget.orig/doc/sample.wgetrc 2005-11-25 14:01:03.531250000 -0600
+++ wget/doc/sample.wgetrc      2005-11-25 23:32:58.463478100 -0600
@@ -110,3 +110,6 @@ waitretry = 10
 # To have Wget follow FTP links from HTML files by default, set this
 # to on:
 #follow_ftp = off
+
+# Setting this to off makes Wget not follow HTTP redirections:
+#redirections = on
diff -uprN -x .svn wget.orig/doc/wget.texi wget/doc/wget.texi
--- wget.orig/doc/wget.texi     2005-11-25 14:01:03.546875000 -0600
+++ wget/doc/wget.texi  2005-11-25 23:33:17.806980500 -0600
@@ -2587,6 +2587,10 @@ Hosts}).
 Follow @sc{ftp} links from @sc{html} documents---the same as
 @samp{--follow-ftp}.
 
[EMAIL PROTECTED] redirections/off
+Follow HTTP redirection targets after receiving 3xx status
+codes---the same as @samp{--redirections}.
+
 @item follow_tags = @var{string}
 Only follow certain @sc{html} tags when doing a recursive retrieval,
 just like @[EMAIL PROTECTED]
diff -uprN -x .svn wget.orig/src/ChangeLog wget/src/ChangeLog
--- wget.orig/src/ChangeLog     2005-11-25 14:00:53.015625000 -0600
+++ wget/src/ChangeLog  2005-11-25 23:35:56.414325300 -0600
@@ -1,3 +1,13 @@
+2005-11-25  Keith Moore  <[EMAIL PROTECTED]>
+
+       * options.h: Added redirections option.
+
+       * init.c: Added --redirections switch.
+
+       * main.c: Ditto.
+
+       * retr.c: Honor new --redirections switch.
+
 2005-11-23  Mauro Tortonesi  <[EMAIL PROTECTED]>
 
        * http.c: Refactored HTTP code. Added support for
diff -uprN -x .svn wget.orig/src/init.c wget/src/init.c
--- wget.orig/src/init.c        2005-11-25 14:00:52.984375000 -0600
+++ wget/src/init.c     2005-11-25 23:32:03.057937300 -0600
@@ -210,6 +210,7 @@ static struct {
   { "readtimeout",     &opt.read_timeout,      cmd_time },
   { "reclevel",                &opt.reclevel,          cmd_number_inf },
   { "recursive",       NULL,                   cmd_spec_recursive },
+  { "redirections",    &opt.redirections,      cmd_boolean },
   { "referer",         &opt.referer,           cmd_string },
   { "reject",          &opt.rejects,           cmd_vector },
   { "relativeonly",    &opt.relative_only,     cmd_boolean },
@@ -313,6 +314,8 @@ defaults (void)
   opt.restrict_files_os = restrict_windows;
 #endif
   opt.restrict_files_ctrl = true;
+
+  opt.redirections = true;
 }
 
 /* Return the user's home directory (strdup-ed), or NULL if none is
diff -uprN -x .svn wget.orig/src/main.c wget/src/main.c
--- wget.orig/src/main.c        2005-11-25 14:00:53.046875000 -0600
+++ wget/src/main.c     2005-11-25 23:36:46.835554900 -0600
@@ -216,6 +216,7 @@ static struct cmdline_option option_data
     { "random-wait", 0, OPT_BOOLEAN, "randomwait", -1 },
     { "read-timeout", 0, OPT_VALUE, "readtimeout", -1 },
     { "recursive", 'r', OPT_BOOLEAN, "recursive", -1 },
+    { "redirections", 0, OPT_BOOLEAN, "redirections", -1 },
     { "referer", 0, OPT_VALUE, "referer", -1 },
     { "reject", 'R', OPT_VALUE, "reject", -1 },
     { "relative", 'L', OPT_BOOLEAN, "relativeonly", -1 },
@@ -611,6 +612,8 @@ Recursive accept/reject:\n"),
   -X,  --exclude-directories=LIST  list of excluded directories.\n"),
     N_("\
   -np, --no-parent                 don't ascend to the parent directory.\n"),
+    N_("\
+       --redirections              follow redirection targets from HTTP 
requests.\n"),
     "\n",
 
     N_("Mail bug reports and suggestions to <[EMAIL PROTECTED]>.\n")
diff -uprN -x .svn wget.orig/src/options.h wget/src/options.h
--- wget.orig/src/options.h     2005-11-25 14:00:52.968750000 -0600
+++ wget/src/options.h  2005-11-25 23:31:23.980312500 -0600
@@ -220,6 +220,7 @@ struct options
     prefer_none
   } prefer_family;             /* preferred address family when more
                                   than one type is available */
+  bool redirections;           /* follow redirection targets */
 };
 
 extern struct options opt;
diff -uprN -x .svn wget.orig/src/retr.c wget/src/retr.c
--- wget.orig/src/retr.c        2005-11-25 14:00:53.031250000 -0600
+++ wget/src/retr.c     2005-11-25 23:32:17.385878900 -0600
@@ -748,10 +748,13 @@ retrieve_url (const char *origurl, char 
       mynewloc = xstrdup (newloc_parsed->url);
 
       /* Check for max. number of redirections.  */
-      if (++redirection_count > MAX_REDIRECTIONS)
+      if (!opt.redirections || ++redirection_count > MAX_REDIRECTIONS)
        {
-         logprintf (LOG_NOTQUIET, _("%d redirections exceeded.\n"),
-                    MAX_REDIRECTIONS);
+         if (!opt.redirections)
+           logprintf (LOG_NOTQUIET, _("redirections disabled.\n"));
+         else
+           logprintf (LOG_NOTQUIET, _("%d redirections exceeded.\n"),
+                      MAX_REDIRECTIONS);
          url_free (newloc_parsed);
          url_free (u);
          xfree (url);

Reply via email to