Created
November 17, 2015 13:06
-
-
Save milabs/c2c71b410bb725ea7a5a to your computer and use it in GitHub Desktop.
Using URI::Fetch cached
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use URI::Fetch; | |
use Cache::File; | |
use HTTP::Status qw(:constants); | |
$url = 'http://127.0.0.1:8080/media/snapshot.json.gz'; | |
$cache = Cache::File->new(cache_root => '/tmp/cache'); | |
$response = URI::Fetch->fetch($url, ForceResponse => 1, Cache => $cache); | |
if ($response->http_status == HTTP_OK) { | |
printf("200 OK\n"); | |
} elsif ($response->http_status == HTTP_NOT_MODIFIED) { | |
printf("304 NOT MODIFIED\n"); | |
} else { | |
printf("ERROR\n"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment