X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=lib%2FY%2FAoC%2FUA.pm;h=725832406839ec5cc230add3ead9b4467d2184a9;hb=073fe39005345f037e5fdcd48e1586f61eb29d11;hp=ecee1b0721e8adca9d52ece1762e552fce35419d;hpb=22e31bf0848564ec5d66066308c7db2e383f6128;p=aoc.git diff --git a/lib/Y/AoC/UA.pm b/lib/Y/AoC/UA.pm index ecee1b0..7258324 100644 --- a/lib/Y/AoC/UA.pm +++ b/lib/Y/AoC/UA.pm @@ -19,7 +19,7 @@ sub request($url, $args) { $cachefile = $cache_dir . '/' . $args->{cache_to}; $cache = Mojo::File->new("$cachefile"); - if ($args->{max_age}) { + if (defined $args->{max_age}) { $cache->remove if $cache->stat && time - $cache->stat->mtime @@ -29,7 +29,9 @@ sub request($url, $args) { if ($cache->stat) { say "\n", white('cached'), " response from $cachefile"; - return Mojo::DOM->new($cache->slurp); + return $args->{body} + ? $cache->slurp + : Mojo::DOM->new($cache->slurp); } }