SVN: toys/rsget.pl/RSGet: Captcha.pm HTTPRequest.pm

sparky sparky at pld-linux.org
Wed Jul 7 14:54:28 CEST 2010


Author: sparky
Date: Wed Jul  7 14:54:28 2010
New Revision: 11633

Modified:
   toys/rsget.pl/RSGet/Captcha.pm
   toys/rsget.pl/RSGet/HTTPRequest.pm
Log:
- added timeout to captcha list


Modified: toys/rsget.pl/RSGet/Captcha.pm
==============================================================================
--- toys/rsget.pl/RSGet/Captcha.pm	(original)
+++ toys/rsget.pl/RSGet/Captcha.pm	Wed Jul  7 14:54:28 2010
@@ -85,7 +85,7 @@
 	}
 
 	# add to ask list
-	$needed{ $md5 } = [ $self->{content_type}, $self->{captcha_data} ];
+	$needed{ $md5 } = [ $self->{content_type}, $self->{captcha_data}, $self->{captcha_until} ];
 	$self->linedata( captcha => $md5 );
 }
 

Modified: toys/rsget.pl/RSGet/HTTPRequest.pm
==============================================================================
--- toys/rsget.pl/RSGet/HTTPRequest.pm	(original)
+++ toys/rsget.pl/RSGet/HTTPRequest.pm	Wed Jul  7 14:54:28 2010
@@ -697,11 +697,17 @@
 		$headers->{Content_Type} = "text/plain";
 		return $post->{solve};
 	} elsif ( my $n = $RSGet::Captcha::needed{ $md5 } ) {
-		( $ct, my $dataref ) = @$n;
+		( $ct, my $dataref, my $until ) = @$n;
 		$data = $$dataref;
 	} else {
-		$headers->{Content_Type} = "text/plain";
-		return join "\n", keys %RSGet::Captcha::needed, '';
+		$ct = "text/plain";
+		$data = "";
+		my $time = time;
+		foreach my $md5 ( sort {
+				$RSGet::Captcha::needed{ $a }->[2] <=> $RSGet::Captcha::needed{ $b }->[2]
+					or $a cmp $b } keys %RSGet::Captcha::needed ) {
+			$data .= $md5 . "\t" . ( $RSGet::Captcha::needed{ $md5 }->[2] - $time ) . "\n";
+		}
 	}
 
 	$headers->{Content_Type} = $ct;


More information about the pld-cvs-commit mailing list