mirror of
https://github.com/pragma-/pbot.git
synced 2025-01-11 04:22:35 +01:00
WebPaste: use LWP::UserAgent::Paranoid for stricter timeout
This commit is contained in:
parent
b89d41796f
commit
19386a7a51
1
MODULES
1
MODULES
@ -20,6 +20,7 @@ Lingua::Stem
|
||||
LWP::Protocol::https
|
||||
LWP::Simple
|
||||
LWP::UserAgent
|
||||
LWP::UserAgent::Paranoid
|
||||
LWP::UserAgent::WithCache
|
||||
Math::Expression::Evaluator
|
||||
Math::Units
|
||||
|
@ -16,7 +16,7 @@ use feature 'unicode_strings';
|
||||
|
||||
use Time::HiRes qw/gettimeofday/;
|
||||
use Time::Duration;
|
||||
use LWP::UserAgent;
|
||||
use LWP::UserAgent::Paranoid;
|
||||
use Carp ();
|
||||
use Encode;
|
||||
|
||||
@ -68,7 +68,7 @@ sub paste {
|
||||
$text = encode('UTF-8', $text);
|
||||
|
||||
my $result;
|
||||
for (my $tries = 5; $tries > 0; $tries--) {
|
||||
for (my $tries = 3; $tries > 0; $tries--) {
|
||||
my $paste_site = $self->get_paste_site;
|
||||
$result = $paste_site->($text);
|
||||
|
||||
@ -83,10 +83,9 @@ sub paste {
|
||||
sub paste_ixio {
|
||||
my ($self, $text) = @_;
|
||||
|
||||
my $ua = LWP::UserAgent->new();
|
||||
my $ua = LWP::UserAgent::Paranoid->new(request_timeout => 3);
|
||||
$ua->agent("Mozilla/5.0");
|
||||
push @{ $ua->requests_redirectable }, 'POST';
|
||||
$ua->timeout(10);
|
||||
|
||||
my %post = ('f:1' => $text);
|
||||
my $response = $ua->post("http://ix.io", \%post);
|
||||
|
Loading…
Reference in New Issue
Block a user