SYNOPSIS

Main purpose is to get the content of the target document that we need to parse. Takes care of get/post differences, redirects, cookies, and 401 autentication.


USAGE

First, create the object:

 # setup the page fetcher
 my $fetcher = PageFetcher->new;

Set some data members:

 # get or post?
 $fetcher->request_method(CGI::request_method());
 # let the fetcher know of the target to fetch
 $fetcher->target($parsed_info->{target});
 # provide access to the util functions
 $fetcher->{_util} = $utils;
 # pass only post params 
 # this will only pass post parameters
 # get params remain intact on self->target
 $fetcher->post_params({Vars});
 $fetcher->cookie_manager($cookie_man);

Fetch content:

 # $config is a hash reference to luci configuration vars
 $content = $fetcher->fetch_content($config);


DESCRIPTION

fetch_content

The only parameter is a hash reference to the Luci configuration variables. The LWP::UserAgent is setup for a request, and then fetch_response is called to get a response from the server of the target document. This response could contain the content we need, or it could be a redirection - in which case a recursive request is set into action.

returns the HTML content of the target document.

example:

 $content = $fetcher->fetch_content($config);

fetch_response

Fetch a response object from the target document's web server. This sorts out 401 authentication and presents a custom login form to the user if login is necessary. For redirect, fetch_response will recurse to get the final response object. (uses fetch_final_location to sort through redirection headers and find the proper target) The final response object is stored in the member variable _response.

returns nothing. results are stored in _response member variable.

example: used internally

fetch_final_location

Sorts through the attributes of a response object and looks for redirection. This will recurse if there is an embedded response object that is a redirect itself, but it may also contain another redirect property. The _target member variable is set to the deepest nested redirect URL found.

returns nothing. The _target member variable is modified with the results.

example: used internally

post_params

Sets or gets the post parameters that should be sent if the target is requested through POST as opposed to GET. The post parameters are set by passing a hash reference to key/value pairs, and a hash reference to the current post parameters is returned if the function is called with no arguments.

returns a hash reference if no arguments are used.

example:

 # Vars is from the CGI module
 $fetcher->post_params({Vars});


LUCI DOCUMENTATION

See Luci Documentation for more information.


AUTHORS