W3C home > Mailing lists > Public > www-validator-cvs@w3.org > June 2006

perl/modules/W3C/LogValidator/lib/W3C/LogValidator Basic.pm,1.13,1.14

From: Olivier Thereaux via cvs-syncmail <cvsmail@w3.org>
Date: Thu, 22 Jun 2006 05:09:02 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1FtHR8-0004QY-4a@lionel-hutz.w3.org>

Update of /sources/public/perl/modules/W3C/LogValidator/lib/W3C/LogValidator
In directory hutz:/tmp/cvs-serv16127/lib/W3C/LogValidator

Modified Files:
	Basic.pm 
Log Message:
Since the module is supposed to list most popular resources, it should 
probably limit its listing to actual resources, not 404s, etc. 
For now, mmodifying it to only show (if we know that info) resources that 
returned a 2xx or 3xx HTTP status code.
This should probably be made an option at some point.


Index: Basic.pm
===================================================================
RCS file: /sources/public/perl/modules/W3C/LogValidator/lib/W3C/LogValidator/Basic.pm,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- Basic.pm	9 Sep 2005 06:33:11 -0000	1.13
+++ Basic.pm	22 Jun 2006 05:09:00 -0000	1.14
@@ -101,15 +101,17 @@
 
 	print "Now Using the Basic module... \n" if $verbose;
 	my %hits;
+	my %HTTPcodes;
 	my @uris = undef;
+	use DB_File; 
 	if (defined ($config{tmpfile}))
 	{
-		use DB_File; 
 		my $tmp_file = $config{tmpfile};
 		tie (%hits, 'DB_File', "$tmp_file", O_RDONLY) || 
 		    die ("Cannot create or open $tmp_file");
 		@uris = sort { $hits{$b} <=> $hits{$a} } keys %hits;
 	}
+
 	elsif ($self->uris())
 	{
 		@uris = $self->uris();
@@ -118,6 +120,15 @@
 
         @uris = $self->trim_uris(@uris);
 
+
+	if (defined ($config{tmpfile_HTTP_codes}))
+	{
+		my $tmp_file_HTTP_codes = $config{tmpfile_HTTP_codes};
+		tie (%HTTPcodes, 'DB_File', "$tmp_file_HTTP_codes", O_RDONLY) || 
+		    die ("Cannot create or open $tmp_file_HTTP_codes");
+	}
+
+
 	my $intro="Here are the <census> most popular documents overall for $name.";
 	my @result;
 	my @result_head;
@@ -130,11 +141,16 @@
 		my $uri = shift (@uris);
 		chomp ($uri);
 		my @result_tmp;
-		$census++;
-		push @result_tmp, "$census";
-		push @result_tmp, "$hits{$uri}";
-		push @result_tmp, "$uri";
-		push @result, [@result_tmp];
+		if ($HTTPcodes{$uri} eq "200")
+#(!defined $HTTPcodes{$uri}) or ($HTTPcodes{$uri} eq "") or ( $HTTPcodes{$uri} =~ /^[2-3]/))
+		{ # This module should ignore requests that resulted in 4XX and 5XX codes
+		    $census++;
+		    push @result_tmp, "$census";
+		    push @result_tmp, "$hits{$uri}";
+		    push @result_tmp, "$uri";
+		    push @result, [@result_tmp];
+		}
+		else { print "$uri returned code $HTTPcodes{$uri}, ignoring \n"; }
 	}
 	print "Done!\n" if $verbose;
 	if ($census eq 1) # let's repect grammar here
Received on Thursday, 22 June 2006 05:09:04 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:02:17 UTC