Arch::LiteWeb3pm
Simple way to access web pages
Usage
my $web = Arch::LiteWeb->new;my $content = $web->get("http://some.domain:81/some/path");die $web->error . " while processing " . $web->request_urlunless $content;my $content_type = $web->response_headers->{content_type};
Overview
This class provides a basic and easy to use support for the client-side HTTP. It is supplied in order to avoid dependency on LWP. If such dependency is not a problem, consider to use LWP instead that provides much better support for HTTP and other protocols.
Methods
The following class methods are available:
get, post, request_url, error, error_with_url, network_error, response_code, response_codestr, response_error, response_headers, response_content.
geturl [params ...]-
Execute HTTP get of the given url and return the html string or undef on network/response error. Use other methods to get the details about the error and the response.
params is key-value hash, the following keys are supported:
url_host - only used if url is noneurl_port - only used if url is none (80)url_path - only used if url is noneendl - default is "\015\012"timeout - default is 20 secondsuser_agent - default is "Arch::LiteWeb/0.1"nocache - add a no-cache headernoredirect - don't follow redirect responsesmax_redirect_depth - default is 5use_proxy - default is falseproxy_url - proxy url ($http_proxy supported too)proxy_host - only used if proxy_url is noneproxy_port - only used if proxy_url is none (80)
posturl input [params]-
Not implemented yet.
request_url-
Actual url of the last issued request or undef. If partial redirect responses are enabled, then the result is the last (non-redirect) url.
error-
If the last request resulted in error (i.e.
get/postreturned undef), then this method returns the error message, otherwise it returns undef. This is just a shortcut fornetwork_error||response_error.
error_with_url-
Like error, but with "\nwhile fetching request_url\n" text appended if non undef.
network_error-
The network error message for the last request or undef.
response_error-
The response error message for the last request or undef.
response_code-
The last response code (integer) or undef.
response_codestr-
The last response code (string) or undef.
response_headers-
The last response headers (hashref of HTTP headers) or undef.
response_content-
The last response content or undef. This is the same thing that the last
get/postreturns.
Releases
8 releases since Debian 4.0 (Etch); the text changed 3 times.