829 lines
28 KiB
HTML
829 lines
28 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of LWP</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>LWP</H1>
|
|
Section: User Contributed Perl Documentation (3pm)<BR>Updated: 2019-11-29<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
LWP - The World-Wide Web library for Perl
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
use LWP;
|
|
print "This is libwww-perl-$LWP::VERSION\n";
|
|
|
|
</PRE>
|
|
|
|
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
|
|
|
|
The libwww-perl collection is a set of Perl modules which provides a
|
|
simple and consistent application programming interface (<FONT SIZE="-1">API</FONT>) to the
|
|
World-Wide Web. The main focus of the library is to provide classes
|
|
and functions that allow you to write <FONT SIZE="-1">WWW</FONT> clients. The library also
|
|
contain modules that are of more general use and even classes that
|
|
help you implement simple <FONT SIZE="-1">HTTP</FONT> servers.
|
|
<P>
|
|
|
|
Most modules in this library provide an object oriented <FONT SIZE="-1">API.</FONT> The user
|
|
agent, requests sent and responses received from the <FONT SIZE="-1">WWW</FONT> server are
|
|
all represented by objects. This makes a simple and powerful
|
|
interface to these services. The interface is easy to extend
|
|
and customize for your own needs.
|
|
<P>
|
|
|
|
The main features of the library are:
|
|
<DL COMPACT>
|
|
<DT id="1">•<DD>
|
|
Contains various reusable components (modules) that can be
|
|
used separately or together.
|
|
<DT id="2">•<DD>
|
|
Provides an object oriented model of HTTP-style communication. Within
|
|
this framework we currently support access to <TT>"http"</TT>, <TT>"https"</TT>, <TT>"gopher"</TT>,
|
|
<TT>"ftp"</TT>, <TT>"news"</TT>, <TT>"file"</TT>, and <TT>"mailto"</TT> resources.
|
|
<DT id="3">•<DD>
|
|
Provides a full object oriented interface or
|
|
a very simple procedural interface.
|
|
<DT id="4">•<DD>
|
|
Supports the basic and digest authorization schemes.
|
|
<DT id="5">•<DD>
|
|
Supports transparent redirect handling.
|
|
<DT id="6">•<DD>
|
|
Supports access through proxy servers.
|
|
<DT id="7">•<DD>
|
|
Provides parser for <I>robots.txt</I> files and a framework for constructing robots.
|
|
<DT id="8">•<DD>
|
|
Supports parsing of <FONT SIZE="-1">HTML</FONT> forms.
|
|
<DT id="9">•<DD>
|
|
Implements <FONT SIZE="-1">HTTP</FONT> content negotiation algorithm that can
|
|
be used both in protocol modules and in server scripts (like <FONT SIZE="-1">CGI</FONT>
|
|
scripts).
|
|
<DT id="10">•<DD>
|
|
Supports <FONT SIZE="-1">HTTP</FONT> cookies.
|
|
<DT id="11">•<DD>
|
|
Some simple command line clients, for instance <TT>"lwp-request"</TT> and <TT>"lwp-download"</TT>.
|
|
</DL>
|
|
<A NAME="lbAE"> </A>
|
|
<H2>HTTP STYLE COMMUNICATION</H2>
|
|
|
|
|
|
|
|
The libwww-perl library is based on <FONT SIZE="-1">HTTP</FONT> style communication. This
|
|
section tries to describe what that means.
|
|
<P>
|
|
|
|
Let us start with this quote from the <FONT SIZE="-1">HTTP</FONT> specification document
|
|
<URL:<A HREF="http://www.w3.org/Protocols/">http://www.w3.org/Protocols/</A>>:
|
|
<DL COMPACT>
|
|
<DT id="12">•<DD>
|
|
The <FONT SIZE="-1">HTTP</FONT> protocol is based on a request/response paradigm. A client
|
|
establishes a connection with a server and sends a request to the
|
|
server in the form of a request method, <FONT SIZE="-1">URI,</FONT> and protocol version,
|
|
followed by a MIME-like message containing request modifiers, client
|
|
information, and possible body content. The server responds with a
|
|
status line, including the message's protocol version and a success or
|
|
error code, followed by a MIME-like message containing server
|
|
information, entity meta-information, and possible body content.
|
|
</DL>
|
|
<P>
|
|
|
|
What this means to libwww-perl is that communication always take place
|
|
through these steps: First a <I>request</I> object is created and
|
|
configured. This object is then passed to a server and we get a
|
|
<I>response</I> object in return that we can examine. A request is always
|
|
independent of any previous requests, i.e. the service is stateless.
|
|
The same simple model is used for any kind of service we want to
|
|
access.
|
|
<P>
|
|
|
|
For example, if we want to fetch a document from a remote file server,
|
|
then we send it a request that contains a name for that document and
|
|
the response will contain the document itself. If we access a search
|
|
engine, then the content of the request will contain the query
|
|
parameters and the response will contain the query result. If we want
|
|
to send a mail message to somebody then we send a request object which
|
|
contains our message to the mail server and the response object will
|
|
contain an acknowledgment that tells us that the message has been
|
|
accepted and will be forwarded to the recipient(s).
|
|
<P>
|
|
|
|
It is as simple as that!
|
|
<A NAME="lbAF"> </A>
|
|
<H3>The Request Object</H3>
|
|
|
|
|
|
|
|
The libwww-perl request object has the class name HTTP::Request.
|
|
The fact that the class name uses <TT>"HTTP::"</TT> as a
|
|
prefix only implies that we use the <FONT SIZE="-1">HTTP</FONT> model of communication. It
|
|
does not limit the kind of services we can try to pass this <I>request</I>
|
|
to. For instance, we will send HTTP::Requests both to ftp and
|
|
gopher servers, as well as to the local file system.
|
|
<P>
|
|
|
|
The main attributes of the request objects are:
|
|
<DL COMPACT>
|
|
<DT id="13">•<DD>
|
|
<B>method</B> is a short string that tells what kind of
|
|
request this is. The most common methods are <B></B><FONT SIZE="-1"><B>GET</B></FONT><B></B>, <B></B><FONT SIZE="-1"><B>PUT</B></FONT><B></B>,
|
|
<B></B><FONT SIZE="-1"><B>POST</B></FONT><B></B> and <B></B><FONT SIZE="-1"><B>HEAD</B></FONT><B></B>.
|
|
<DT id="14">•<DD>
|
|
<B>uri</B> is a string denoting the protocol, server and
|
|
the name of the ``document'' we want to access. The <B>uri</B> might
|
|
also encode various other parameters.
|
|
<DT id="15">•<DD>
|
|
<B>headers</B> contains additional information about the
|
|
request and can also used to describe the content. The headers
|
|
are a set of keyword/value pairs.
|
|
<DT id="16">•<DD>
|
|
<B>content</B> is an arbitrary amount of data.
|
|
</DL>
|
|
<A NAME="lbAG"> </A>
|
|
<H3>The Response Object</H3>
|
|
|
|
|
|
|
|
The libwww-perl response object has the class name HTTP::Response.
|
|
The main attributes of objects of this class are:
|
|
<DL COMPACT>
|
|
<DT id="17">•<DD>
|
|
<B>code</B> is a numerical value that indicates the overall
|
|
outcome of the request.
|
|
<DT id="18">•<DD>
|
|
<B>message</B> is a short, human readable string that
|
|
corresponds to the <I>code</I>.
|
|
<DT id="19">•<DD>
|
|
<B>headers</B> contains additional information about the
|
|
response and describe the content.
|
|
<DT id="20">•<DD>
|
|
<B>content</B> is an arbitrary amount of data.
|
|
</DL>
|
|
<P>
|
|
|
|
Since we don't want to handle all possible <I>code</I> values directly in
|
|
our programs, a libwww-perl response object has methods that can be
|
|
used to query what kind of response this is. The most commonly used
|
|
response classification methods are:
|
|
<DL COMPACT>
|
|
<DT id="21"><B>is_success()</B><DD>
|
|
|
|
|
|
The request was successfully received, understood or accepted.
|
|
<DT id="22"><B>is_error()</B><DD>
|
|
|
|
|
|
The request failed. The server or the resource might not be
|
|
available, access to the resource might be denied or other things might
|
|
have failed for some reason.
|
|
</DL>
|
|
<A NAME="lbAH"> </A>
|
|
<H3>The User Agent</H3>
|
|
|
|
|
|
|
|
Let us assume that we have created a <I>request</I> object. What do we
|
|
actually do with it in order to receive a <I>response</I>?
|
|
<P>
|
|
|
|
The answer is that you pass it to a <I>user agent</I> object and this
|
|
object takes care of all the things that need to be done
|
|
(like low-level communication and error handling) and returns
|
|
a <I>response</I> object. The user agent represents your
|
|
application on the network and provides you with an interface that
|
|
can accept <I>requests</I> and return <I>responses</I>.
|
|
<P>
|
|
|
|
The user agent is an interface layer between
|
|
your application code and the network. Through this interface you are
|
|
able to access the various servers on the network.
|
|
<P>
|
|
|
|
The class name for the user agent is LWP::UserAgent. Every
|
|
libwww-perl application that wants to communicate should create at
|
|
least one object of this class. The main method provided by this
|
|
object is <B>request()</B>. This method takes an HTTP::Request object as
|
|
argument and (eventually) returns a HTTP::Response object.
|
|
<P>
|
|
|
|
The user agent has many other attributes that let you
|
|
configure how it will interact with the network and with your
|
|
application.
|
|
<DL COMPACT>
|
|
<DT id="23">•<DD>
|
|
<B>timeout</B> specifies how much time we give remote servers to
|
|
respond before the library disconnects and creates an
|
|
internal <I>timeout</I> response.
|
|
<DT id="24">•<DD>
|
|
<B>agent</B> specifies the name that your application uses when it
|
|
presents itself on the network.
|
|
<DT id="25">•<DD>
|
|
<B>from</B> can be set to the e-mail address of the person
|
|
responsible for running the application. If this is set, then the
|
|
address will be sent to the servers with every request.
|
|
<DT id="26">•<DD>
|
|
<B>parse_head</B> specifies whether we should initialize response
|
|
headers from the <head> section of <FONT SIZE="-1">HTML</FONT> documents.
|
|
<DT id="27">•<DD>
|
|
<B>proxy</B> and <B>no_proxy</B> specify if and when to go through
|
|
a proxy server. <URL:<A HREF="http://www.w3.org/History/1994/WWW/Proxies/">http://www.w3.org/History/1994/WWW/Proxies/</A>>
|
|
<DT id="28">•<DD>
|
|
<B>credentials</B> provides a way to set up user names and
|
|
passwords needed to access certain services.
|
|
</DL>
|
|
<P>
|
|
|
|
Many applications want even more control over how they interact
|
|
with the network and they get this by sub-classing
|
|
LWP::UserAgent. The library includes a
|
|
sub-class, LWP::RobotUA, for robot applications.
|
|
<A NAME="lbAI"> </A>
|
|
<H3>An Example</H3>
|
|
|
|
|
|
|
|
This example shows how the user agent, a request and a response are
|
|
represented in actual perl code:
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
# Create a user agent object
|
|
use LWP::UserAgent;
|
|
my $ua = LWP::UserAgent->new;
|
|
$ua->agent("MyApp/0.1 ");
|
|
|
|
# Create a request
|
|
my $req = HTTP::Request->new(POST => '<A HREF="http://search.cpan.org/search');">http://search.cpan.org/search');</A>
|
|
$req->content_type('application/x-www-form-urlencoded');
|
|
$req->content('query=libwww-perl&mode=dist');
|
|
|
|
# Pass request to the user agent and get a response back
|
|
my $res = $ua->request($req);
|
|
|
|
# Check the outcome of the response
|
|
if ($res->is_success) {
|
|
print $res->content;
|
|
}
|
|
else {
|
|
print $res->status_line, "\n";
|
|
}
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
The <TT>$ua</TT> is created once when the application starts up. New request
|
|
objects should normally created for each request sent.
|
|
<A NAME="lbAJ"> </A>
|
|
<H2>NETWORK SUPPORT</H2>
|
|
|
|
|
|
|
|
This section discusses the various protocol schemes and
|
|
the <FONT SIZE="-1">HTTP</FONT> style methods that headers may be used for each.
|
|
<P>
|
|
|
|
For all requests, a ``User-Agent'' header is added and initialized from
|
|
the <TT>$ua</TT>->agent attribute before the request is handed to the network
|
|
layer. In the same way, a ``From'' header is initialized from the
|
|
<TT>$ua</TT>->from attribute.
|
|
<P>
|
|
|
|
For all responses, the library adds a header called ``Client-Date''.
|
|
This header holds the time when the response was received by
|
|
your application. The format and semantics of the header are the
|
|
same as the server created ``Date'' header. You may also encounter other
|
|
``Client-XXX'' headers. They are all generated by the library
|
|
internally and are not received from the servers.
|
|
<A NAME="lbAK"> </A>
|
|
<H3><FONT SIZE="-1">HTTP</FONT> Requests</H3>
|
|
|
|
|
|
|
|
<FONT SIZE="-1">HTTP</FONT> requests are just handed off to an <FONT SIZE="-1">HTTP</FONT> server and it
|
|
decides what happens. Few servers implement methods beside the usual
|
|
``<FONT SIZE="-1">GET'', ``HEAD'', ``POST''</FONT> and ``<FONT SIZE="-1">PUT'',</FONT> but CGI-scripts may implement
|
|
any method they like.
|
|
<P>
|
|
|
|
If the server is not available then the library will generate an
|
|
internal error response.
|
|
<P>
|
|
|
|
The library automatically adds a ``Host'' and a ``Content-Length'' header
|
|
to the <FONT SIZE="-1">HTTP</FONT> request before it is sent over the network.
|
|
<P>
|
|
|
|
For a <FONT SIZE="-1">GET</FONT> request you might want to add a ``If-Modified-Since'' or
|
|
``If-None-Match'' header to make the request conditional.
|
|
<P>
|
|
|
|
For a <FONT SIZE="-1">POST</FONT> request you should add the ``Content-Type'' header. When you
|
|
try to emulate <FONT SIZE="-1">HTML</FONT> <<FONT SIZE="-1">FORM</FONT>> handling you should usually let the value
|
|
of the ``Content-Type'' header be ``application/x-www-form-urlencoded''.
|
|
See lwpcook for examples of this.
|
|
<P>
|
|
|
|
The libwww-perl <FONT SIZE="-1">HTTP</FONT> implementation currently support the <FONT SIZE="-1">HTTP/1.1</FONT>
|
|
and <FONT SIZE="-1">HTTP/1.0</FONT> protocol.
|
|
<P>
|
|
|
|
The library allows you to access proxy server through <FONT SIZE="-1">HTTP.</FONT> This
|
|
means that you can set up the library to forward all types of request
|
|
through the <FONT SIZE="-1">HTTP</FONT> protocol module. See LWP::UserAgent for
|
|
documentation of this.
|
|
<A NAME="lbAL"> </A>
|
|
<H3><FONT SIZE="-1">HTTPS</FONT> Requests</H3>
|
|
|
|
|
|
|
|
<FONT SIZE="-1">HTTPS</FONT> requests are <FONT SIZE="-1">HTTP</FONT> requests over an encrypted network connection
|
|
using the <FONT SIZE="-1">SSL</FONT> protocol developed by Netscape. Everything about <FONT SIZE="-1">HTTP</FONT>
|
|
requests above also apply to <FONT SIZE="-1">HTTPS</FONT> requests. In addition the library
|
|
will add the headers ``Client-SSL-Cipher'', ``Client-SSL-Cert-Subject'' and
|
|
``Client-SSL-Cert-Issuer'' to the response. These headers denote the
|
|
encryption method used and the name of the server owner.
|
|
<P>
|
|
|
|
The request can contain the header ``If-SSL-Cert-Subject'' in order to
|
|
make the request conditional on the content of the server certificate.
|
|
If the certificate subject does not match, no request is sent to the
|
|
server and an internally generated error response is returned. The
|
|
value of the ``If-SSL-Cert-Subject'' header is interpreted as a Perl
|
|
regular expression.
|
|
<A NAME="lbAM"> </A>
|
|
<H3><FONT SIZE="-1">FTP</FONT> Requests</H3>
|
|
|
|
|
|
|
|
The library currently supports <FONT SIZE="-1">GET, HEAD</FONT> and <FONT SIZE="-1">PUT</FONT> requests. <FONT SIZE="-1">GET</FONT>
|
|
retrieves a file or a directory listing from an <FONT SIZE="-1">FTP</FONT> server. <FONT SIZE="-1">PUT</FONT>
|
|
stores a file on a ftp server.
|
|
<P>
|
|
|
|
You can specify a ftp account for servers that want this in addition
|
|
to user name and password. This is specified by including an ``Account''
|
|
header in the request.
|
|
<P>
|
|
|
|
User name/password can be specified using basic authorization or be
|
|
encoded in the <FONT SIZE="-1">URL.</FONT> Failed logins return an <FONT SIZE="-1">UNAUTHORIZED</FONT> response with
|
|
``WWW-Authenticate: Basic'' and can be treated like basic authorization
|
|
for <FONT SIZE="-1">HTTP.</FONT>
|
|
<P>
|
|
|
|
The library supports ftp <FONT SIZE="-1">ASCII</FONT> transfer mode by specifying the ``type=a''
|
|
parameter in the <FONT SIZE="-1">URL.</FONT> It also supports transfer of ranges for <FONT SIZE="-1">FTP</FONT> transfers
|
|
using the ``Range'' header.
|
|
<P>
|
|
|
|
Directory listings are by default returned unprocessed (as returned
|
|
from the ftp server) with the content media type reported to be
|
|
``text/ftp-dir-listing''. The File::Listing module provides methods
|
|
for parsing of these directory listing.
|
|
<P>
|
|
|
|
The ftp module is also able to convert directory listings to <FONT SIZE="-1">HTML</FONT> and
|
|
this can be requested via the standard <FONT SIZE="-1">HTTP</FONT> content negotiation
|
|
mechanisms (add an ``Accept: text/html'' header in the request if you
|
|
want this).
|
|
<P>
|
|
|
|
For normal file retrievals, the ``Content-Type'' is guessed based on the
|
|
file name suffix. See LWP::MediaTypes.
|
|
<P>
|
|
|
|
The ``If-Modified-Since'' request header works for servers that implement
|
|
the <TT>"MDTM"</TT> command. It will probably not work for directory listings though.
|
|
<P>
|
|
|
|
Example:
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
$req = HTTP::Request->new(GET => '<A HREF="ftp://me:passwd@ftp.some.where.com/');">ftp://me:passwd@ftp.some.where.com/');</A>
|
|
$req->header(Accept => "text/html, */*;q=0.1");
|
|
|
|
</PRE>
|
|
|
|
|
|
<A NAME="lbAN"> </A>
|
|
<H3>News Requests</H3>
|
|
|
|
|
|
|
|
Access to the <FONT SIZE="-1">USENET</FONT> News system is implemented through the <FONT SIZE="-1">NNTP</FONT>
|
|
protocol. The name of the news server is obtained from the
|
|
<FONT SIZE="-1">NNTP_SERVER</FONT> environment variable and defaults to ``news''. It is not
|
|
possible to specify the hostname of the <FONT SIZE="-1">NNTP</FONT> server in news: URLs.
|
|
<P>
|
|
|
|
The library supports <FONT SIZE="-1">GET</FONT> and <FONT SIZE="-1">HEAD</FONT> to retrieve news articles through the
|
|
<FONT SIZE="-1">NNTP</FONT> protocol. You can also post articles to newsgroups by using
|
|
(surprise!) the <FONT SIZE="-1">POST</FONT> method.
|
|
<P>
|
|
|
|
<FONT SIZE="-1">GET</FONT> on newsgroups is not implemented yet.
|
|
<P>
|
|
|
|
Examples:
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
$req = HTTP::Request->new(GET => 'news:<A HREF="mailto:abc1234@a.sn.no">abc1234@a.sn.no</A>');
|
|
|
|
$req = HTTP::Request->new(POST => 'news:comp.lang.perl.test');
|
|
$req->header(Subject => 'This is a test',
|
|
From => '<A HREF="mailto:me@some.where.org">me@some.where.org</A>');
|
|
$req->content(<<EOT);
|
|
This is the content of the message that we are sending to
|
|
the world.
|
|
EOT
|
|
|
|
</PRE>
|
|
|
|
|
|
<A NAME="lbAO"> </A>
|
|
<H3>Gopher Request</H3>
|
|
|
|
|
|
|
|
The library supports the <FONT SIZE="-1">GET</FONT> and <FONT SIZE="-1">HEAD</FONT> methods for gopher requests. All
|
|
request header values are ignored. <FONT SIZE="-1">HEAD</FONT> cheats and returns a
|
|
response without even talking to server.
|
|
<P>
|
|
|
|
Gopher menus are always converted to <FONT SIZE="-1">HTML.</FONT>
|
|
<P>
|
|
|
|
The response ``Content-Type'' is generated from the document type
|
|
encoded (as the first letter) in the request <FONT SIZE="-1">URL</FONT> path itself.
|
|
<P>
|
|
|
|
Example:
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
$req = HTTP::Request->new(GET => '<A HREF="gopher://gopher.sn.no/');">gopher://gopher.sn.no/');</A>
|
|
|
|
</PRE>
|
|
|
|
|
|
<A NAME="lbAP"> </A>
|
|
<H3>File Request</H3>
|
|
|
|
|
|
|
|
The library supports <FONT SIZE="-1">GET</FONT> and <FONT SIZE="-1">HEAD</FONT> methods for file requests. The
|
|
``If-Modified-Since'' header is supported. All other headers are
|
|
ignored. The <I>host</I> component of the file <FONT SIZE="-1">URL</FONT> must be empty or set
|
|
to ``localhost''. Any other <I>host</I> value will be treated as an error.
|
|
<P>
|
|
|
|
Directories are always converted to an <FONT SIZE="-1">HTML</FONT> document. For normal
|
|
files, the ``Content-Type'' and ``Content-Encoding'' in the response are
|
|
guessed based on the file suffix.
|
|
<P>
|
|
|
|
Example:
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
$req = HTTP::Request->new(GET => 'file:/etc/passwd');
|
|
|
|
</PRE>
|
|
|
|
|
|
<A NAME="lbAQ"> </A>
|
|
<H3>Mailto Request</H3>
|
|
|
|
|
|
|
|
You can send (aka ``<FONT SIZE="-1">POST''</FONT>) mail messages using the library. All
|
|
headers specified for the request are passed on to the mail system.
|
|
The ``To'' header is initialized from the mail address in the <FONT SIZE="-1">URL.</FONT>
|
|
<P>
|
|
|
|
Example:
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
$req = HTTP::Request->new(POST => 'mailto:<A HREF="mailto:libwww@perl.org">libwww@perl.org</A>');
|
|
$req->header(Subject => "subscribe");
|
|
$req->content("Please subscribe me to the libwww-perl mailing list!\n");
|
|
|
|
</PRE>
|
|
|
|
|
|
<A NAME="lbAR"> </A>
|
|
<H3><FONT SIZE="-1">CPAN</FONT> Requests</H3>
|
|
|
|
|
|
|
|
URLs with scheme <TT>"cpan:"</TT> are redirected to a suitable <FONT SIZE="-1">CPAN</FONT>
|
|
mirror. If you have your own local mirror of <FONT SIZE="-1">CPAN</FONT> you might tell <FONT SIZE="-1">LWP</FONT>
|
|
to use it for <TT>"cpan:"</TT> URLs by an assignment like this:
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
$LWP::Protocol::cpan::CPAN = "file:/local/CPAN/";
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
Suitable <FONT SIZE="-1">CPAN</FONT> mirrors are also picked up from the configuration for
|
|
the <FONT SIZE="-1">CPAN</FONT>.pm, so if you have used that module a suitable mirror should
|
|
be picked automatically. If neither of these apply, then a redirect
|
|
to the generic <FONT SIZE="-1">CPAN</FONT> http location is issued.
|
|
<P>
|
|
|
|
Example request to download the newest perl:
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
$req = HTTP::Request->new(GET => "cpan:src/latest.tar.gz");
|
|
|
|
</PRE>
|
|
|
|
|
|
<A NAME="lbAS"> </A>
|
|
<H2>OVERVIEW OF CLASSES AND PACKAGES</H2>
|
|
|
|
|
|
|
|
This table should give you a quick overview of the classes provided by the
|
|
library. Indentation shows class inheritance.
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
LWP::MemberMixin -- Access to member variables of Perl5 classes
|
|
LWP::UserAgent -- WWW user agent class
|
|
LWP::RobotUA -- When developing a robot applications
|
|
LWP::Protocol -- Interface to various protocol schemes
|
|
LWP::Protocol::http -- http:// access
|
|
LWP::Protocol::file -- file:// access
|
|
LWP::Protocol::ftp -- ftp:// access
|
|
...
|
|
|
|
LWP::Authen::Basic -- Handle 401 and 407 responses
|
|
LWP::Authen::Digest
|
|
|
|
HTTP::Headers -- MIME/RFC822 style header (used by HTTP::Message)
|
|
HTTP::Message -- HTTP style message
|
|
HTTP::Request -- HTTP request
|
|
HTTP::Response -- HTTP response
|
|
HTTP::Daemon -- A HTTP server class
|
|
|
|
WWW::RobotRules -- Parse robots.txt files
|
|
WWW::RobotRules::AnyDBM_File -- Persistent RobotRules
|
|
|
|
Net::HTTP -- Low level HTTP client
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
The following modules provide various functions and definitions.
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
LWP -- This file. Library version number and documentation.
|
|
LWP::MediaTypes -- MIME types configuration (text/html etc.)
|
|
LWP::Simple -- Simplified procedural interface for common functions
|
|
HTTP::Status -- HTTP status code (200 OK etc)
|
|
HTTP::Date -- Date parsing module for HTTP date formats
|
|
HTTP::Negotiate -- HTTP content negotiation calculation
|
|
File::Listing -- Parse directory listings
|
|
HTML::Form -- Processing for <form>s in HTML documents
|
|
|
|
</PRE>
|
|
|
|
|
|
<A NAME="lbAT"> </A>
|
|
<H2>MORE DOCUMENTATION</H2>
|
|
|
|
|
|
|
|
All modules contain detailed information on the interfaces they
|
|
provide. The lwpcook manpage is the libwww-perl cookbook that contain
|
|
examples of typical usage of the library. You might want to take a
|
|
look at how the scripts lwp-request, lwp-download, lwp-dump
|
|
and lwp-mirror are implemented.
|
|
<A NAME="lbAU"> </A>
|
|
<H2>ENVIRONMENT</H2>
|
|
|
|
|
|
|
|
The following environment variables are used by <FONT SIZE="-1">LWP:</FONT>
|
|
<DL COMPACT>
|
|
<DT id="29"><FONT SIZE="-1">HOME</FONT><DD>
|
|
|
|
|
|
The LWP::MediaTypes functions will look for the <I>.media.types</I> and
|
|
<I>.mime.types</I> files relative to you home directory.
|
|
<DT id="30">http_proxy<DD>
|
|
|
|
|
|
|
|
<DT id="31">ftp_proxy<DD>
|
|
|
|
|
|
<DT id="32">xxx_proxy<DD>
|
|
|
|
|
|
<DT id="33">no_proxy<DD>
|
|
|
|
|
|
|
|
These environment variables can be set to enable communication through
|
|
a proxy server. See the description of the <TT>"env_proxy"</TT> method in
|
|
LWP::UserAgent.
|
|
<DT id="34"><FONT SIZE="-1">PERL_LWP_ENV_PROXY</FONT><DD>
|
|
|
|
|
|
If set to a <FONT SIZE="-1">TRUE</FONT> value, then the LWP::UserAgent will by default call
|
|
<TT>"env_proxy"</TT> during initialization. This makes <FONT SIZE="-1">LWP</FONT> honor the proxy variables
|
|
described above.
|
|
<DT id="35"><FONT SIZE="-1">PERL_LWP_SSL_VERIFY_HOSTNAME</FONT><DD>
|
|
|
|
|
|
The default <TT>"verify_hostname"</TT> setting for LWP::UserAgent. If
|
|
not set the default will be 1. Set it as 0 to disable hostname
|
|
verification (the default prior to libwww-perl 5.840.
|
|
<DT id="36"><FONT SIZE="-1">PERL_LWP_SSL_CA_FILE</FONT><DD>
|
|
|
|
|
|
|
|
<DT id="37"><FONT SIZE="-1">PERL_LWP_SSL_CA_PATH</FONT><DD>
|
|
|
|
|
|
|
|
The file and/or directory
|
|
where the trusted Certificate Authority certificates
|
|
is located. See LWP::UserAgent for details.
|
|
<DT id="38"><FONT SIZE="-1">PERL_HTTP_URI_CLASS</FONT><DD>
|
|
|
|
|
|
Used to decide what <FONT SIZE="-1">URI</FONT> objects to instantiate. The default is <FONT SIZE="-1">URI</FONT>.
|
|
You might want to set it to <FONT SIZE="-1">URI::URL</FONT> for compatibility with old times.
|
|
</DL>
|
|
<A NAME="lbAV"> </A>
|
|
<H2>AUTHORS</H2>
|
|
|
|
|
|
|
|
<FONT SIZE="-1">LWP</FONT> was made possible by contributions from Adam Newby, Albert
|
|
Dvornik, Alexandre Duret-Lutz, Andreas Gustafsson, Andreas König,
|
|
Andrew Pimlott, Andy Lester, Ben Coleman, Benjamin Low, Ben Low, Ben
|
|
Tilly, Blair Zajac, Bob Dalgleish, BooK, Brad Hughes, Brian
|
|
J. Murrell, Brian McCauley, Charles C. Fu, Charles Lane, Chris Nandor,
|
|
Christian Gilmore, Chris W. Unger, Craig Macdonald, Dale Couch, Dan
|
|
Kubb, Dave Dunkin, Dave W. Smith, David Coppit, David Dick, David
|
|
D. Kilzer, Doug MacEachern, Edward Avis, erik, Gary Shea, Gisle Aas,
|
|
Graham Barr, Gurusamy Sarathy, Hans de Graaff, Harald Joerg, Harry
|
|
Bochner, Hugo, Ilya Zakharevich, <FONT SIZE="-1">INOUE</FONT> Yoshinari, Ivan Panchenko, Jack
|
|
Shirazi, James Tillman, Jan Dubois, Jared Rhine, Jim Stern, Joao
|
|
Lopes, John Klar, Johnny Lee, Josh Kronengold, Josh Rai, Joshua
|
|
Chamas, Joshua Hoblitt, Kartik Subbarao, Keiichiro Nagano, Ken
|
|
Williams, <FONT SIZE="-1">KONISHI</FONT> Katsuhiro, Lee T Lindley, Liam Quinn, Marc Hedlund,
|
|
Marc Langheinrich, Mark D. Anderson, Marko Asplund, Mark Stosberg,
|
|
Markus B Krüger, Markus Laker, Martijn Koster, Martin Thurn, Matthew
|
|
Eldridge, Matthew.van.Eerde, Matt Sergeant, Michael A. Chase, Michael
|
|
Quaranta, Michael Thompson, Mike Schilli, Moshe Kaminsky, Nathan
|
|
Torkington, Nicolai Langfeldt, Norton Allen, Olly Betts, Paul
|
|
J. Schinder, peterm, Philip Guenther, Daniel Buenzli, Pon Hwa Lin,
|
|
Radoslaw Zielinski, Radu Greab, Randal L. Schwartz, Richard Chen,
|
|
Robin Barker, Roy Fielding, Sander van Zoest, Sean M. Burke,
|
|
shildreth, Slaven Rezic, Steve A Fink, Steve Hay, Steven Butler,
|
|
Steve_Kilbane, Takanori Ugai, Thomas Lotterer, Tim Bunce, Tom Hughes,
|
|
Tony Finch, Ville Skyttä, Ward Vandewege, William York, Yale Huang,
|
|
and Yitzchak Scott-Thoennes.
|
|
<P>
|
|
|
|
<FONT SIZE="-1">LWP</FONT> owes a lot in motivation, design, and code, to the libwww-perl
|
|
library for Perl4 by Roy Fielding, which included work from Alberto
|
|
Accomazzi, James Casey, Brooks Cutter, Martijn Koster, Oscar
|
|
Nierstrasz, Mel Melchner, Gertjan van Oosten, Jared Rhine, Jack
|
|
Shirazi, Gene Spafford, Marc VanHeyningen, Steven E. Brenner, Marion
|
|
Hakanson, Waldemar Kebsch, Tony Sanders, and Larry Wall; see the
|
|
libwww-perl-0.40 library for details.
|
|
<A NAME="lbAW"> </A>
|
|
<H2>COPYRIGHT</H2>
|
|
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Copyright 1995-2009, Gisle Aas
|
|
Copyright 1995, Martijn Koster
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
modify it under the same terms as Perl itself.
|
|
<A NAME="lbAX"> </A>
|
|
<H2>AVAILABILITY</H2>
|
|
|
|
|
|
|
|
The latest version of this library is likely to be available from <FONT SIZE="-1">CPAN</FONT>
|
|
as well as:
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
<A HREF="http://github.com/libwww-perl/libwww-perl">http://github.com/libwww-perl/libwww-perl</A>
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
The best place to discuss this code is on the <<A HREF="mailto:libwww@perl.org">libwww@perl.org</A>>
|
|
mailing list.
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="39"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="40"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="41"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="42"><A HREF="#lbAE">HTTP STYLE COMMUNICATION</A><DD>
|
|
<DL>
|
|
<DT id="43"><A HREF="#lbAF">The Request Object</A><DD>
|
|
<DT id="44"><A HREF="#lbAG">The Response Object</A><DD>
|
|
<DT id="45"><A HREF="#lbAH">The User Agent</A><DD>
|
|
<DT id="46"><A HREF="#lbAI">An Example</A><DD>
|
|
</DL>
|
|
<DT id="47"><A HREF="#lbAJ">NETWORK SUPPORT</A><DD>
|
|
<DL>
|
|
<DT id="48"><A HREF="#lbAK"><FONT SIZE="-1">HTTP</FONT> Requests</A><DD>
|
|
<DT id="49"><A HREF="#lbAL"><FONT SIZE="-1">HTTPS</FONT> Requests</A><DD>
|
|
<DT id="50"><A HREF="#lbAM"><FONT SIZE="-1">FTP</FONT> Requests</A><DD>
|
|
<DT id="51"><A HREF="#lbAN">News Requests</A><DD>
|
|
<DT id="52"><A HREF="#lbAO">Gopher Request</A><DD>
|
|
<DT id="53"><A HREF="#lbAP">File Request</A><DD>
|
|
<DT id="54"><A HREF="#lbAQ">Mailto Request</A><DD>
|
|
<DT id="55"><A HREF="#lbAR"><FONT SIZE="-1">CPAN</FONT> Requests</A><DD>
|
|
</DL>
|
|
<DT id="56"><A HREF="#lbAS">OVERVIEW OF CLASSES AND PACKAGES</A><DD>
|
|
<DT id="57"><A HREF="#lbAT">MORE DOCUMENTATION</A><DD>
|
|
<DT id="58"><A HREF="#lbAU">ENVIRONMENT</A><DD>
|
|
<DT id="59"><A HREF="#lbAV">AUTHORS</A><DD>
|
|
<DT id="60"><A HREF="#lbAW">COPYRIGHT</A><DD>
|
|
<DT id="61"><A HREF="#lbAX">AVAILABILITY</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:47 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|