From c6f3a9aab4c071273d506a7c9c130b429959c58d Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Sat, 8 Feb 2020 20:49:14 -0800 Subject: [PATCH] Util/LWPUserAgentCached: minor style clean-up --- PBot/Utils/LWPUserAgentCached.pm | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/PBot/Utils/LWPUserAgentCached.pm b/PBot/Utils/LWPUserAgentCached.pm index fb5038f7..e2056e3b 100644 --- a/PBot/Utils/LWPUserAgentCached.pm +++ b/PBot/Utils/LWPUserAgentCached.pm @@ -39,22 +39,12 @@ sub new { sub request { my ($self, @args) = @_; my $request = $args[0]; - return $self->SUPER::request(@args) if $request->method ne 'GET'; - my $uri = $request->uri->as_string; my $cached = $self->{cache}->get($uri); - - if (defined $cached) { - return HTTP::Response->parse($cached); - } - + return HTTP::Response->parse($cached) if defined $cached; my $res = $self->SUPER::request(@args); - - if ($res->code eq HTTP::Status::RC_OK) { - $self->{cache}->set($uri, $res->as_string); - } - + $self->{cache}->set($uri, $res->as_string) if $res->code eq HTTP::Status::RC_OK; return $res; }