NAME

AmphetaDesk::WWW - Network access from within AmphetaDesk

SYNOPSIS

    my $full_data     = get($url);
    my $headers       = head($url);
    my $response      = getstore($url, $filepath);
    my $response      = mirror($url, $filepath);
    my $response      = getprint($url); # sends to STDOUT

DESCRIPTION

This module handles all of the various "get crap from the net" routines of AmphetaDesk. Most of these functions are simply wrappers around LWP::UserAgent code, which does all the real work. This code is aware of proxy settings that the user has implemented, as well as version numbers for the User-Agent string, etc.

Only get, getprint, getstore, and mirror are exported - you can import head yourself if you really need it. The following command lines will adequately test if there's a problem with the AmphetaDesk network code, or if it's something related to the user's network, Perl installation, or "proven" code:

 perl -MLWP::Simple -e "getprint('http://disobey.com/')"

 cd /path/to/AmphetaDesk/lib/
 perl -MAmphetaDesk::WWW -e "getprint('http://disobey.com/')"

METHODS

get($url)
This routine takes the passed $url and sucks down all the data into a string which is returned. It's proxy aware and supports redirects if the $url has temporarily or permanently moved. It'll return 0 if the final response code is anything outside the 2xx range.
getprint($url)
This routine takes the passed $url and spits the data to STDOUT. It's proxy aware and supports redirects if the $url has temporarily or permanently moved. It'll return 0 if the final response code is anything outside the 2xx range and 1 otherwise.
getstore($url, $file)
This routine takes the passed $url and sucks down all the data into $file (overwriting anything within $file if it already exists). It's proxy aware and supports redirects if the $url has temporarily or permanently moved. It'll return 0 if the final response code is anything outside the 2xx range, or if the file could not be opened, and 1 if the downloading and file storing was successful.
head($url)
This routine takes the passed $url, sucks down the HTTP headers and returns them. It's proxy aware and supports redirects if the $url has temporarily or permanently moved. It'll return 0 if the final response code is anything outside the 2xx range. Compare to get, which returns the full data.
mirror($url, $file)
mirror takes a look at the $url and compares the Content-length and Last-Modified HTTP headers with the $file size and modification date on the local machine. If they differ, it downloads the new data to the $file and returns a success of 1 - if the file doesn't need updating, or something else happens, it returns with a 0.

SEE ALSO

AUTHOR

Morbus Iff, <morbus@disobey.com>

COPYRIGHT AND LICENSE

Copyright 2000-2004 Morbus Iff <morbus@disobey.com>

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.