Neil Bowers > URI-Fetch > URI::Fetch

Download:
URI-Fetch-0.10.tar.gz

Dependencies

Annotate this POD

Website

CPAN RT

New  2
Open  1
View/Report Bugs
Module Version: 0.10   Source  

NAME ^

URI::Fetch - Smart URI fetching/caching

SYNOPSIS ^

    use URI::Fetch;

    ## Simple fetch.
    my $res = URI::Fetch->fetch('http://example.com/atom.xml')
        or die URI::Fetch->errstr;
    do_something($res->content) if $res->is_success;

    ## Fetch using specified ETag and Last-Modified headers.
    $res = URI::Fetch->fetch('http://example.com/atom.xml',
            ETag => '123-ABC',
            LastModified => time - 3600,
    )
        or die URI::Fetch->errstr;

    ## Fetch using an on-disk cache that URI::Fetch manages for you.
    my $cache = Cache::File->new( cache_root => '/tmp/cache' );
    $res = URI::Fetch->fetch('http://example.com/atom.xml',
            Cache => $cache
    )
        or die URI::Fetch->errstr;

DESCRIPTION ^

URI::Fetch is a smart client for fetching HTTP pages, notably syndication feeds (RSS, Atom, and others), in an intelligent, bandwidth- and time-saving way. That means:

Change from 0.09

If you make a request using a cache and get back a 304 response code (Not Modified), then if the content was returned from the cache, then is_success() will return true, and $response->content will contain the cached content.

I think this is the right behaviour, given the philosophy of URI::Fetch, but please let me (NEILB) know if you disagree.

USAGE ^

URI::Fetch->fetch($uri, %param)

Fetches a page identified by the URI $uri.

On success, returns a URI::Fetch::Response object; on failure, returns undef.

%param can contain:

REPOSITORY ^

https://github.com/neilbowers/URI-Fetch

LICENSE ^

URI::Fetch is free software; you may redistribute it and/or modify it under the same terms as Perl itself.

AUTHOR & COPYRIGHT ^

Except where otherwise noted, URI::Fetch is Copyright 2004 Benjamin Trott, ben+cpan@stupidfool.org. All rights reserved.

syntax highlighting: