W3C home > Mailing lists > Public > www-validator-cvs@w3.org > December 2009

perl/modules/W3C/LinkChecker/bin checklink,4.170,4.171 checklink.pod,1.27,1.28

From: Ville Skytta via cvs-syncmail <cvsmail@w3.org>
Date: Thu, 03 Dec 2009 21:28:11 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1NGJDf-00012M-Cm@lionel-hutz.w3.org>
Update of /sources/public/perl/modules/W3C/LinkChecker/bin
In directory hutz:/tmp/cvs-serv3923/bin

Modified Files:
	checklink checklink.pod 
Log Message:
Add support for cookies (command line mode only for now).

Index: checklink
===================================================================
RCS file: /sources/public/perl/modules/W3C/LinkChecker/bin/checklink,v
retrieving revision 4.170
retrieving revision 4.171
diff -u -d -r4.170 -r4.171
--- checklink	3 Dec 2009 20:36:39 -0000	4.170
+++ checklink	3 Dec 2009 21:28:09 -0000	4.171
@@ -396,6 +396,7 @@
     Redirects         => 1,
     Dir_Redirects     => 1,
     Accept_Language   => $cmdline ? undef : $ENV{HTTP_ACCEPT_LANGUAGE},
+    Cookies           => undef,
     No_Referer        => 0,
     Hide_Same_Realm   => 0,
     Depth             => 0,    # < 0 means unlimited recursion.
@@ -445,6 +446,17 @@
   $ua->delay($Opts{Sleep_Time}/60);
 }
 $ua->timeout($Opts{Timeout});
+# Set up cookie stash if requested
+if (defined($Opts{Cookies})) {
+  require HTTP::Cookies;
+  my $cookie_file = $Opts{Cookies};
+  if ($cookie_file eq 'tmp') {
+    $cookie_file = undef;
+  } elsif ($cookie_file =~ /^(.*)$/) {
+    $cookie_file = $1; # untaint
+  }
+  $ua->cookie_jar(HTTP::Cookies->new(file => $cookie_file, autosave => 1));
+}
 eval {
   $ua->allow_private_ips($Opts{Allow_Private_IPs});
 };
@@ -658,6 +670,7 @@
              't|timeout=i'     => \$Opts{Timeout},
              'S|sleep=i'       => \$Opts{Sleep_Time},
              'L|languages=s'   => \$Opts{Accept_Language},
+             'c|cookies=s'     => \$Opts{Cookies},
              'R|no-referer'    => \$Opts{No_Referer},
              'D|depth=i'       => sub { $Opts{Depth} = $_[1]
                                           unless $_[1] == 0; },
@@ -797,6 +810,8 @@
                             specified multiple times.
  -L, --languages LANGS      Accept-Language header to send.  The special value
                             'auto' causes autodetection from the environment.
+ -c, --cookies FILE         Use cookies, load/save them in FILE.  The special
+                            value 'tmp' causes non-persistent use of cookies.
  -R, --no-referer           Do not send the Referer HTTP header.
  -q, --quiet                No output if no errors are found (implies -s).
  -v, --verbose              Verbose mode.
@@ -971,12 +986,22 @@
     my $s = $Opts{Sleep_Time} == 1 ? '' : 's';
     my $acclang = $Opts{Accept_Language} || '(not sent)';
     my $send_referer = $Opts{No_Referer} ? 'not sent' : 'sending';
-    printf(<<'EOF', $Accept, $acclang, $send_referer, $Opts{Sleep_Time}, $s);
+    my $cookies = 'not used';
+    if (defined($Opts{Cookies})) {
+      $cookies = 'used, ';
+      if ($Opts{Cookies} eq 'tmp') {
+        $cookies .= 'non-persistent';
+      } else {
+        $cookies .= "file $Opts{Cookies}";
+      }
+    }
+    printf(<<'EOF', $Accept, $acclang, $send_referer, $cookies, $Opts{Sleep_Time}, $s);
 
 Settings used:
 - Accept: %s
 - Accept-Language: %s
 - Referer: %s
+- Cookies: %s
 - Sleeping %d second%s between requests to each server
 EOF
     printf("- Excluding links matching %s\n", $Opts{Exclude})

Index: checklink.pod
===================================================================
RCS file: /sources/public/perl/modules/W3C/LinkChecker/bin/checklink.pod,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- checklink.pod	4 Nov 2009 18:44:17 -0000	1.27
+++ checklink.pod	3 Dec 2009 21:28:09 -0000	1.28
@@ -116,6 +116,12 @@
 if found.  In CGI mode, the default is to send the value received from
 the client as is.
 
+=item B<-c, --cookies> I<cookie-file>
+
+Use cookies, load/save them in I<cookie-file>.  The special value
+C<tmp> causes non-persistent use of cookies, i.e. they are used but
+only stored in memory for the duration of this link checker run.
+
 =item B<-R, --no-referer>
 
 Do not send the C<Referer> HTTP header.
Received on Thursday, 3 December 2009 21:28:12 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Thursday, 26 April 2012 12:55:16 GMT