- LICENSE AND COPYRIGHT
LWP::UserAgent::Caching::Simple - The first 'hard thing' made easy --- simple
use LWP::UserAgent::Caching::Simple; my $ua = LWP::UserAgent::Caching::Simple->new; my $resp = $ua->get( 'http://example.com/cached?' );
and maybe even something quick:
# use a built-in default User-Agent for quick one timers use LWP::UserAgent::Caching::Simple qw(get_from_json); my $hashref = get_from_json ( 'http://example.com/cached?', 'Cache-Control' => 'max-stale', # without delta-seconds, unlimited 'Cache-Control' => 'no-transform', # something not implemented );
This is a simplified version of LWP::UserAgent::Caching with sensible defaults and less options. For more control and more options, please use that module.
Since this is a subclass of LWP::UserAgent::Caching it has it's methods, like the following object methods:
This will simply make a GET request to a server, with the
Accept Header set to
application/json. On succes, it will turn the returned json (as requested) into a perl data structure. Otherwise it will be
undef and print a warning.
This is a super simplified way of making a straightforward request. It can handle more complex requests as well, using
my $resp = $ua->request($http_rqst);
which will give a full
HTTP::Response object back. The UserAgent is a full subclass of the standard LWP::UserAgent, and one can still change the setting of that, like e.g. the
Theo van Hoesel,
<Th.J.v.Hoesel at THEMA-MEDIA.nl>
Copyright 2016 .. 2018 Theo van Hoesel.