]> www.fi.muni.cz Git - aoc.git/blobdiff - lib/Y/AoC/UA.pm
Infrastructure mods
[aoc.git] / lib / Y / AoC / UA.pm
index ecee1b0721e8adca9d52ece1762e552fce35419d..725832406839ec5cc230add3ead9b4467d2184a9 100644 (file)
@@ -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);
                }
        }