mirror of
https://github.com/pragma-/pbot.git
synced 2025-02-16 21:40:46 +01:00
Util/LWPUserAgentCached: minor style clean-up
This commit is contained in:
parent
9d3392ecae
commit
c6f3a9aab4
@ -39,22 +39,12 @@ sub new {
|
|||||||
sub request {
|
sub request {
|
||||||
my ($self, @args) = @_;
|
my ($self, @args) = @_;
|
||||||
my $request = $args[0];
|
my $request = $args[0];
|
||||||
|
|
||||||
return $self->SUPER::request(@args) if $request->method ne 'GET';
|
return $self->SUPER::request(@args) if $request->method ne 'GET';
|
||||||
|
|
||||||
my $uri = $request->uri->as_string;
|
my $uri = $request->uri->as_string;
|
||||||
my $cached = $self->{cache}->get($uri);
|
my $cached = $self->{cache}->get($uri);
|
||||||
|
return HTTP::Response->parse($cached) if defined $cached;
|
||||||
if (defined $cached) {
|
|
||||||
return HTTP::Response->parse($cached);
|
|
||||||
}
|
|
||||||
|
|
||||||
my $res = $self->SUPER::request(@args);
|
my $res = $self->SUPER::request(@args);
|
||||||
|
$self->{cache}->set($uri, $res->as_string) if $res->code eq HTTP::Status::RC_OK;
|
||||||
if ($res->code eq HTTP::Status::RC_OK) {
|
|
||||||
$self->{cache}->set($uri, $res->as_string);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user