Add built local::lib
[catagits/Gitalist.git] / local-lib5 / man / man3 / LWP.3pm
1 .\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.3
2 .\"
3 .\" Standard preamble:
4 .\" ========================================================================
5 .de Sh \" Subsection heading
6 .br
7 .if t .Sp
8 .ne 5
9 .PP
10 \fB\\$1\fR
11 .PP
12 ..
13 .de Sp \" Vertical space (when we can't use .PP)
14 .if t .sp .5v
15 .if n .sp
16 ..
17 .de Vb \" Begin verbatim text
18 .ft CW
19 .nf
20 .ne \\$1
21 ..
22 .de Ve \" End verbatim text
23 .ft R
24 .fi
25 ..
26 .\" Set up some character translations and predefined strings.  \*(-- will
27 .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
28 .\" double quote, and \*(R" will give a right double quote.  | will give a
29 .\" real vertical bar.  \*(C+ will give a nicer C++.  Capital omega is used to
30 .\" do unbreakable dashes and therefore won't be available.  \*(C` and \*(C'
31 .\" expand to `' in nroff, nothing in troff, for use with C<>.
32 .tr \(*W-|\(bv\*(Tr
33 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
34 .ie n \{\
35 .    ds -- \(*W-
36 .    ds PI pi
37 .    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
38 .    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
39 .    ds L" ""
40 .    ds R" ""
41 .    ds C` ""
42 .    ds C' ""
43 'br\}
44 .el\{\
45 .    ds -- \|\(em\|
46 .    ds PI \(*p
47 .    ds L" ``
48 .    ds R" ''
49 'br\}
50 .\"
51 .\" If the F register is turned on, we'll generate index entries on stderr for
52 .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
53 .\" entries marked with X<> in POD.  Of course, you'll have to process the
54 .\" output yourself in some meaningful fashion.
55 .if \nF \{\
56 .    de IX
57 .    tm Index:\\$1\t\\n%\t"\\$2"
58 ..
59 .    nr % 0
60 .    rr F
61 .\}
62 .\"
63 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
64 .\" way too many mistakes in technical documents.
65 .hy 0
66 .if n .na
67 .\"
68 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
69 .\" Fear.  Run.  Save yourself.  No user-serviceable parts.
70 .    \" fudge factors for nroff and troff
71 .if n \{\
72 .    ds #H 0
73 .    ds #V .8m
74 .    ds #F .3m
75 .    ds #[ \f1
76 .    ds #] \fP
77 .\}
78 .if t \{\
79 .    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
80 .    ds #V .6m
81 .    ds #F 0
82 .    ds #[ \&
83 .    ds #] \&
84 .\}
85 .    \" simple accents for nroff and troff
86 .if n \{\
87 .    ds ' \&
88 .    ds ` \&
89 .    ds ^ \&
90 .    ds , \&
91 .    ds ~ ~
92 .    ds /
93 .\}
94 .if t \{\
95 .    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
96 .    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
97 .    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
98 .    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
99 .    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
100 .    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
101 .\}
102 .    \" troff and (daisy-wheel) nroff accents
103 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
104 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
105 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
106 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
107 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
108 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
109 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
110 .ds ae a\h'-(\w'a'u*4/10)'e
111 .ds Ae A\h'-(\w'A'u*4/10)'E
112 .    \" corrections for vroff
113 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
114 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
115 .    \" for low resolution devices (crt and lpr)
116 .if \n(.H>23 .if \n(.V>19 \
117 \{\
118 .    ds : e
119 .    ds 8 ss
120 .    ds o a
121 .    ds d- d\h'-1'\(ga
122 .    ds D- D\h'-1'\(hy
123 .    ds th \o'bp'
124 .    ds Th \o'LP'
125 .    ds ae ae
126 .    ds Ae AE
127 .\}
128 .rm #[ #] #H #V #F C
129 .\" ========================================================================
130 .\"
131 .IX Title "LWP 3"
132 .TH LWP 3 "2009-11-21" "perl v5.8.7" "User Contributed Perl Documentation"
133 .SH "NAME"
134 LWP \- The World\-Wide Web library for Perl
135 .SH "SYNOPSIS"
136 .IX Header "SYNOPSIS"
137 .Vb 2
138 \&  use LWP;
139 \&  print "This is libwww\-perl\-$LWP::VERSION\en";
140 .Ve
141 .SH "DESCRIPTION"
142 .IX Header "DESCRIPTION"
143 The libwww-perl collection is a set of Perl modules which provides a
144 simple and consistent application programming interface (\s-1API\s0) to the
145 World-Wide Web.  The main focus of the library is to provide classes
146 and functions that allow you to write \s-1WWW\s0 clients. The library also
147 contain modules that are of more general use and even classes that
148 help you implement simple \s-1HTTP\s0 servers.
149 .PP
150 Most modules in this library provide an object oriented \s-1API\s0.  The user
151 agent, requests sent and responses received from the \s-1WWW\s0 server are
152 all represented by objects.  This makes a simple and powerful
153 interface to these services.  The interface is easy to extend
154 and customize for your own needs.
155 .PP
156 The main features of the library are:
157 .IP "\(bu" 3
158 Contains various reusable components (modules) that can be
159 used separately or together.
160 .IP "\(bu" 3
161 Provides an object oriented model of HTTP-style communication.  Within
162 this framework we currently support access to http, https, gopher, ftp, news,
163 file, and mailto resources.
164 .IP "\(bu" 3
165 Provides a full object oriented interface or
166 a very simple procedural interface.
167 .IP "\(bu" 3
168 Supports the basic and digest authorization schemes.
169 .IP "\(bu" 3
170 Supports transparent redirect handling.
171 .IP "\(bu" 3
172 Supports access through proxy servers.
173 .IP "\(bu" 3
174 Provides parser for \fIrobots.txt\fR files and a framework for constructing robots.
175 .IP "\(bu" 3
176 Supports parsing of \s-1HTML\s0 forms.
177 .IP "\(bu" 3
178 Implements \s-1HTTP\s0 content negotiation algorithm that can
179 be used both in protocol modules and in server scripts (like \s-1CGI\s0
180 scripts).
181 .IP "\(bu" 3
182 Supports \s-1HTTP\s0 cookies.
183 .IP "\(bu" 3
184 Some simple command line clients, for instance \f(CW\*(C`lwp\-request\*(C'\fR and \f(CW\*(C`lwp\-download\*(C'\fR.
185 .SH "HTTP STYLE COMMUNICATION"
186 .IX Header "HTTP STYLE COMMUNICATION"
187 The libwww-perl library is based on \s-1HTTP\s0 style communication. This
188 section tries to describe what that means.
189 .PP
190 Let us start with this quote from the \s-1HTTP\s0 specification document
191 <URL:http://www.w3.org/pub/WWW/Protocols/>:
192 .IP "\(bu" 3
193 The \s-1HTTP\s0 protocol is based on a request/response paradigm. A client
194 establishes a connection with a server and sends a request to the
195 server in the form of a request method, \s-1URI\s0, and protocol version,
196 followed by a MIME-like message containing request modifiers, client
197 information, and possible body content. The server responds with a
198 status line, including the message's protocol version and a success or
199 error code, followed by a MIME-like message containing server
200 information, entity meta\-information, and possible body content.
201 .PP
202 What this means to libwww-perl is that communication always take place
203 through these steps: First a \fIrequest\fR object is created and
204 configured. This object is then passed to a server and we get a
205 \&\fIresponse\fR object in return that we can examine. A request is always
206 independent of any previous requests, i.e. the service is stateless.
207 The same simple model is used for any kind of service we want to
208 access.
209 .PP
210 For example, if we want to fetch a document from a remote file server,
211 then we send it a request that contains a name for that document and
212 the response will contain the document itself.  If we access a search
213 engine, then the content of the request will contain the query
214 parameters and the response will contain the query result.  If we want
215 to send a mail message to somebody then we send a request object which
216 contains our message to the mail server and the response object will
217 contain an acknowledgment that tells us that the message has been
218 accepted and will be forwarded to the recipient(s).
219 .PP
220 It is as simple as that!
221 .Sh "The Request Object"
222 .IX Subsection "The Request Object"
223 The libwww-perl request object has the class name \f(CW\*(C`HTTP::Request\*(C'\fR.
224 The fact that the class name uses \f(CW\*(C`HTTP::\*(C'\fR as a
225 prefix only implies that we use the \s-1HTTP\s0 model of communication.  It
226 does not limit the kind of services we can try to pass this \fIrequest\fR
227 to.  For instance, we will send \f(CW\*(C`HTTP::Request\*(C'\fRs both to ftp and
228 gopher servers, as well as to the local file system.
229 .PP
230 The main attributes of the request objects are:
231 .IP "\(bu" 3
232 The \fBmethod\fR is a short string that tells what kind of
233 request this is.  The most common methods are \fB\s-1GET\s0\fR, \fB\s-1PUT\s0\fR,
234 \&\fB\s-1POST\s0\fR and \fB\s-1HEAD\s0\fR.
235 .IP "\(bu" 3
236 The \fBuri\fR is a string denoting the protocol, server and
237 the name of the \*(L"document\*(R" we want to access.  The \fBuri\fR might
238 also encode various other parameters.
239 .IP "\(bu" 3
240 The \fBheaders\fR contain additional information about the
241 request and can also used to describe the content.  The headers
242 are a set of keyword/value pairs.
243 .IP "\(bu" 3
244 The \fBcontent\fR is an arbitrary amount of data.
245 .Sh "The Response Object"
246 .IX Subsection "The Response Object"
247 The libwww-perl response object has the class name \f(CW\*(C`HTTP::Response\*(C'\fR.
248 The main attributes of objects of this class are:
249 .IP "\(bu" 3
250 The \fBcode\fR is a numerical value that indicates the overall
251 outcome of the request.
252 .IP "\(bu" 3
253 The \fBmessage\fR is a short, human readable string that
254 corresponds to the \fIcode\fR.
255 .IP "\(bu" 3
256 The \fBheaders\fR contain additional information about the
257 response and describe the content.
258 .IP "\(bu" 3
259 The \fBcontent\fR is an arbitrary amount of data.
260 .PP
261 Since we don't want to handle all possible \fIcode\fR values directly in
262 our programs, a libwww-perl response object has methods that can be
263 used to query what kind of response this is.  The most commonly used
264 response classification methods are:
265 .IP "\fIis_success()\fR" 3
266 .IX Item "is_success()"
267 The request was was successfully received, understood or accepted.
268 .IP "\fIis_error()\fR" 3
269 .IX Item "is_error()"
270 The request failed.  The server or the resource might not be
271 available, access to the resource might be denied or other things might
272 have failed for some reason.
273 .Sh "The User Agent"
274 .IX Subsection "The User Agent"
275 Let us assume that we have created a \fIrequest\fR object. What do we
276 actually do with it in order to receive a \fIresponse\fR?
277 .PP
278 The answer is that you pass it to a \fIuser agent\fR object and this
279 object takes care of all the things that need to be done
280 (like low-level communication and error handling) and returns
281 a \fIresponse\fR object. The user agent represents your
282 application on the network and provides you with an interface that
283 can accept \fIrequests\fR and return \fIresponses\fR.
284 .PP
285 The user agent is an interface layer between
286 your application code and the network.  Through this interface you are
287 able to access the various servers on the network.
288 .PP
289 The class name for the user agent is \f(CW\*(C`LWP::UserAgent\*(C'\fR.  Every
290 libwww-perl application that wants to communicate should create at
291 least one object of this class. The main method provided by this
292 object is \fIrequest()\fR. This method takes an \f(CW\*(C`HTTP::Request\*(C'\fR object as
293 argument and (eventually) returns a \f(CW\*(C`HTTP::Response\*(C'\fR object.
294 .PP
295 The user agent has many other attributes that let you
296 configure how it will interact with the network and with your
297 application.
298 .IP "\(bu" 3
299 The \fBtimeout\fR specifies how much time we give remote servers to
300 respond before the library disconnects and creates an
301 internal \fItimeout\fR response.
302 .IP "\(bu" 3
303 The \fBagent\fR specifies the name that your application should use when it
304 presents itself on the network.
305 .IP "\(bu" 3
306 The \fBfrom\fR attribute can be set to the e\-mail address of the person
307 responsible for running the application.  If this is set, then the
308 address will be sent to the servers with every request.
309 .IP "\(bu" 3
310 The \fBparse_head\fR specifies whether we should initialize response
311 headers from the <head> section of \s-1HTML\s0 documents.
312 .IP "\(bu" 3
313 The \fBproxy\fR and \fBno_proxy\fR attributes specify if and when to go through
314 a proxy server. <URL:http://www.w3.org/pub/WWW/Proxies/>
315 .IP "\(bu" 3
316 The \fBcredentials\fR provide a way to set up user names and
317 passwords needed to access certain services.
318 .PP
319 Many applications want even more control over how they interact
320 with the network and they get this by sub-classing
321 \&\f(CW\*(C`LWP::UserAgent\*(C'\fR.  The library includes a
322 sub\-class, \f(CW\*(C`LWP::RobotUA\*(C'\fR, for robot applications.
323 .Sh "An Example"
324 .IX Subsection "An Example"
325 This example shows how the user agent, a request and a response are
326 represented in actual perl code:
327 .PP
328 .Vb 4
329 \&  # Create a user agent object
330 \&  use LWP::UserAgent;
331 \&  my $ua = LWP::UserAgent\->new;
332 \&  $ua\->agent("MyApp/0.1 ");
333 .Ve
334 .PP
335 .Vb 4
336 \&  # Create a request
337 \&  my $req = HTTP::Request\->new(POST => 'http://search.cpan.org/search');
338 \&  $req\->content_type('application/x\-www\-form\-urlencoded');
339 \&  $req\->content('query=libwww\-perl&mode=dist');
340 .Ve
341 .PP
342 .Vb 2
343 \&  # Pass request to the user agent and get a response back
344 \&  my $res = $ua\->request($req);
345 .Ve
346 .PP
347 .Vb 7
348 \&  # Check the outcome of the response
349 \&  if ($res\->is_success) {
350 \&      print $res\->content;
351 \&  }
352 \&  else {
353 \&      print $res\->status_line, "\en";
354 \&  }
355 .Ve
356 .PP
357 The \f(CW$ua\fR is created once when the application starts up.  New request
358 objects should normally created for each request sent.
359 .SH "NETWORK SUPPORT"
360 .IX Header "NETWORK SUPPORT"
361 This section discusses the various protocol schemes and
362 the \s-1HTTP\s0 style methods that headers may be used for each.
363 .PP
364 For all requests, a \*(L"User\-Agent\*(R" header is added and initialized from
365 the \f(CW$ua\fR\->agent attribute before the request is handed to the network
366 layer.  In the same way, a \*(L"From\*(R" header is initialized from the
367 \&\f(CW$ua\fR\->from attribute.
368 .PP
369 For all responses, the library adds a header called \*(L"Client\-Date\*(R".
370 This header holds the time when the response was received by
371 your application.  The format and semantics of the header are the
372 same as the server created \*(L"Date\*(R" header.  You may also encounter other
373 \&\*(L"Client\-XXX\*(R" headers.  They are all generated by the library
374 internally and are not received from the servers.
375 .Sh "\s-1HTTP\s0 Requests"
376 .IX Subsection "HTTP Requests"
377 \&\s-1HTTP\s0 requests are just handed off to an \s-1HTTP\s0 server and it
378 decides what happens.  Few servers implement methods beside the usual
379 \&\*(L"\s-1GET\s0\*(R", \*(L"\s-1HEAD\s0\*(R", \*(L"\s-1POST\s0\*(R" and \*(L"\s-1PUT\s0\*(R", but CGI-scripts may implement
380 any method they like.
381 .PP
382 If the server is not available then the library will generate an
383 internal error response.
384 .PP
385 The library automatically adds a \*(L"Host\*(R" and a \*(L"Content\-Length\*(R" header
386 to the \s-1HTTP\s0 request before it is sent over the network.
387 .PP
388 For a \s-1GET\s0 request you might want to add a \*(L"If\-Modified\-Since\*(R" or
389 \&\*(L"If\-None\-Match\*(R" header to make the request conditional.
390 .PP
391 For a \s-1POST\s0 request you should add the \*(L"Content\-Type\*(R" header.  When you
392 try to emulate \s-1HTML\s0 <\s-1FORM\s0> handling you should usually let the value
393 of the \*(L"Content\-Type\*(R" header be \*(L"application/x\-www\-form\-urlencoded\*(R".
394 See lwpcook for examples of this.
395 .PP
396 The libwww-perl \s-1HTTP\s0 implementation currently support the \s-1HTTP/1\s0.1
397 and \s-1HTTP/1\s0.0 protocol.
398 .PP
399 The library allows you to access proxy server through \s-1HTTP\s0.  This
400 means that you can set up the library to forward all types of request
401 through the \s-1HTTP\s0 protocol module.  See LWP::UserAgent for
402 documentation of this.
403 .Sh "\s-1HTTPS\s0 Requests"
404 .IX Subsection "HTTPS Requests"
405 \&\s-1HTTPS\s0 requests are \s-1HTTP\s0 requests over an encrypted network connection
406 using the \s-1SSL\s0 protocol developed by Netscape.  Everything about \s-1HTTP\s0
407 requests above also apply to \s-1HTTPS\s0 requests.  In addition the library
408 will add the headers \*(L"Client\-SSL\-Cipher\*(R", \*(L"Client\-SSL\-Cert\-Subject\*(R" and
409 \&\*(L"Client\-SSL\-Cert\-Issuer\*(R" to the response.  These headers denote the
410 encryption method used and the name of the server owner.
411 .PP
412 The request can contain the header \*(L"If\-SSL\-Cert\-Subject\*(R" in order to
413 make the request conditional on the content of the server certificate.
414 If the certificate subject does not match, no request is sent to the
415 server and an internally generated error response is returned.  The
416 value of the \*(L"If\-SSL\-Cert\-Subject\*(R" header is interpreted as a Perl
417 regular expression.
418 .Sh "\s-1FTP\s0 Requests"
419 .IX Subsection "FTP Requests"
420 The library currently supports \s-1GET\s0, \s-1HEAD\s0 and \s-1PUT\s0 requests.  \s-1GET\s0
421 retrieves a file or a directory listing from an \s-1FTP\s0 server.  \s-1PUT\s0
422 stores a file on a ftp server.
423 .PP
424 You can specify a ftp account for servers that want this in addition
425 to user name and password.  This is specified by including an \*(L"Account\*(R"
426 header in the request.
427 .PP
428 User name/password can be specified using basic authorization or be
429 encoded in the \s-1URL\s0.  Failed logins return an \s-1UNAUTHORIZED\s0 response with
430 \&\*(L"WWW\-Authenticate: Basic\*(R" and can be treated like basic authorization
431 for \s-1HTTP\s0.
432 .PP
433 The library supports ftp \s-1ASCII\s0 transfer mode by specifying the \*(L"type=a\*(R"
434 parameter in the \s-1URL\s0. It also supports transfer of ranges for \s-1FTP\s0 transfers
435 using the \*(L"Range\*(R" header.
436 .PP
437 Directory listings are by default returned unprocessed (as returned
438 from the ftp server) with the content media type reported to be
439 \&\*(L"text/ftp\-dir\-listing\*(R". The \f(CW\*(C`File::Listing\*(C'\fR module provides methods
440 for parsing of these directory listing.
441 .PP
442 The ftp module is also able to convert directory listings to \s-1HTML\s0 and
443 this can be requested via the standard \s-1HTTP\s0 content negotiation
444 mechanisms (add an \*(L"Accept: text/html\*(R" header in the request if you
445 want this).
446 .PP
447 For normal file retrievals, the \*(L"Content\-Type\*(R" is guessed based on the
448 file name suffix. See LWP::MediaTypes.
449 .PP
450 The \*(L"If\-Modified\-Since\*(R" request header works for servers that implement
451 the \s-1MDTM\s0 command.  It will probably not work for directory listings though.
452 .PP
453 Example:
454 .PP
455 .Vb 2
456 \&  $req = HTTP::Request\->new(GET => 'ftp://me:passwd@ftp.some.where.com/');
457 \&  $req\->header(Accept => "text/html, */*;q=0.1");
458 .Ve
459 .Sh "News Requests"
460 .IX Subsection "News Requests"
461 Access to the \s-1USENET\s0 News system is implemented through the \s-1NNTP\s0
462 protocol.  The name of the news server is obtained from the
463 \&\s-1NNTP_SERVER\s0 environment variable and defaults to \*(L"news\*(R".  It is not
464 possible to specify the hostname of the \s-1NNTP\s0 server in news: URLs.
465 .PP
466 The library supports \s-1GET\s0 and \s-1HEAD\s0 to retrieve news articles through the
467 \&\s-1NNTP\s0 protocol.  You can also post articles to newsgroups by using
468 (surprise!) the \s-1POST\s0 method.
469 .PP
470 \&\s-1GET\s0 on newsgroups is not implemented yet.
471 .PP
472 Examples:
473 .PP
474 .Vb 1
475 \&  $req = HTTP::Request\->new(GET => 'news:abc1234@a.sn.no');
476 .Ve
477 .PP
478 .Vb 7
479 \&  $req = HTTP::Request\->new(POST => 'news:comp.lang.perl.test');
480 \&  $req\->header(Subject => 'This is a test',
481 \&               From    => 'me@some.where.org');
482 \&  $req\->content(<<EOT);
483 \&  This is the content of the message that we are sending to
484 \&  the world.
485 \&  EOT
486 .Ve
487 .Sh "Gopher Request"
488 .IX Subsection "Gopher Request"
489 The library supports the \s-1GET\s0 and \s-1HEAD\s0 methods for gopher requests.  All
490 request header values are ignored.  \s-1HEAD\s0 cheats and returns a
491 response without even talking to server.
492 .PP
493 Gopher menus are always converted to \s-1HTML\s0.
494 .PP
495 The response \*(L"Content\-Type\*(R" is generated from the document type
496 encoded (as the first letter) in the request \s-1URL\s0 path itself.
497 .PP
498 Example:
499 .PP
500 .Vb 1
501 \&  $req = HTTP::Request\->new(GET => 'gopher://gopher.sn.no/');
502 .Ve
503 .Sh "File Request"
504 .IX Subsection "File Request"
505 The library supports \s-1GET\s0 and \s-1HEAD\s0 methods for file requests.  The
506 \&\*(L"If\-Modified\-Since\*(R" header is supported.  All other headers are
507 ignored.  The \fIhost\fR component of the file \s-1URL\s0 must be empty or set
508 to \*(L"localhost\*(R".  Any other \fIhost\fR value will be treated as an error.
509 .PP
510 Directories are always converted to an \s-1HTML\s0 document.  For normal
511 files, the \*(L"Content\-Type\*(R" and \*(L"Content\-Encoding\*(R" in the response are
512 guessed based on the file suffix.
513 .PP
514 Example:
515 .PP
516 .Vb 1
517 \&  $req = HTTP::Request\->new(GET => 'file:/etc/passwd');
518 .Ve
519 .Sh "Mailto Request"
520 .IX Subsection "Mailto Request"
521 You can send (aka \*(L"\s-1POST\s0\*(R") mail messages using the library.  All
522 headers specified for the request are passed on to the mail system.
523 The \*(L"To\*(R" header is initialized from the mail address in the \s-1URL\s0.
524 .PP
525 Example:
526 .PP
527 .Vb 3
528 \&  $req = HTTP::Request\->new(POST => 'mailto:libwww@perl.org');
529 \&  $req\->header(Subject => "subscribe");
530 \&  $req\->content("Please subscribe me to the libwww\-perl mailing list!\en");
531 .Ve
532 .Sh "\s-1CPAN\s0 Requests"
533 .IX Subsection "CPAN Requests"
534 URLs with scheme \f(CW\*(C`cpan:\*(C'\fR are redirected to the a suitable \s-1CPAN\s0
535 mirror.  If you have your own local mirror of \s-1CPAN\s0 you might tell \s-1LWP\s0
536 to use it for \f(CW\*(C`cpan:\*(C'\fR URLs by an assignment like this:
537 .PP
538 .Vb 1
539 \&  $LWP::Protocol::cpan::CPAN = "file:/local/CPAN/";
540 .Ve
541 .PP
542 Suitable \s-1CPAN\s0 mirrors are also picked up from the configuration for
543 the \s-1CPAN\s0.pm, so if you have used that module a suitable mirror should
544 be picked automatically.  If neither of these apply, then a redirect
545 to the generic \s-1CPAN\s0 http location is issued.
546 .PP
547 Example request to download the newest perl:
548 .PP
549 .Vb 1
550 \&  $req = HTTP::Request\->new(GET => "cpan:src/latest.tar.gz");
551 .Ve
552 .SH "OVERVIEW OF CLASSES AND PACKAGES"
553 .IX Header "OVERVIEW OF CLASSES AND PACKAGES"
554 This table should give you a quick overview of the classes provided by the
555 library. Indentation shows class inheritance.
556 .PP
557 .Vb 8
558 \& LWP::MemberMixin   \-\- Access to member variables of Perl5 classes
559 \&   LWP::UserAgent   \-\- WWW user agent class
560 \&     LWP::RobotUA   \-\- When developing a robot applications
561 \&   LWP::Protocol          \-\- Interface to various protocol schemes
562 \&     LWP::Protocol::http  \-\- http:// access
563 \&     LWP::Protocol::file  \-\- file:// access
564 \&     LWP::Protocol::ftp   \-\- ftp:// access
565 \&     ...
566 .Ve
567 .PP
568 .Vb 2
569 \& LWP::Authen::Basic \-\- Handle 401 and 407 responses
570 \& LWP::Authen::Digest
571 .Ve
572 .PP
573 .Vb 5
574 \& HTTP::Headers      \-\- MIME/RFC822 style header (used by HTTP::Message)
575 \& HTTP::Message      \-\- HTTP style message
576 \&   HTTP::Request    \-\- HTTP request
577 \&   HTTP::Response   \-\- HTTP response
578 \& HTTP::Daemon       \-\- A HTTP server class
579 .Ve
580 .PP
581 .Vb 2
582 \& WWW::RobotRules    \-\- Parse robots.txt files
583 \&   WWW::RobotRules::AnyDBM_File \-\- Persistent RobotRules
584 .Ve
585 .PP
586 .Vb 1
587 \& Net::HTTP          \-\- Low level HTTP client
588 .Ve
589 .PP
590 The following modules provide various functions and definitions.
591 .PP
592 .Vb 8
593 \& LWP                \-\- This file.  Library version number and documentation.
594 \& LWP::MediaTypes    \-\- MIME types configuration (text/html etc.)
595 \& LWP::Simple        \-\- Simplified procedural interface for common functions
596 \& HTTP::Status       \-\- HTTP status code (200 OK etc)
597 \& HTTP::Date         \-\- Date parsing module for HTTP date formats
598 \& HTTP::Negotiate    \-\- HTTP content negotiation calculation
599 \& File::Listing      \-\- Parse directory listings
600 \& HTML::Form         \-\- Processing for <form>s in HTML documents
601 .Ve
602 .SH "MORE DOCUMENTATION"
603 .IX Header "MORE DOCUMENTATION"
604 All modules contain detailed information on the interfaces they
605 provide.  The \fIlwpcook\fR manpage is the libwww-perl cookbook that contain
606 examples of typical usage of the library.  You might want to take a
607 look at how the scripts \f(CW\*(C`lwp\-request\*(C'\fR, \f(CW\*(C`lwp\-rget\*(C'\fR and \f(CW\*(C`lwp\-mirror\*(C'\fR
608 are implemented.
609 .SH "ENVIRONMENT"
610 .IX Header "ENVIRONMENT"
611 The following environment variables are used by \s-1LWP:\s0
612 .IP "\s-1HOME\s0" 4
613 .IX Item "HOME"
614 The \f(CW\*(C`LWP::MediaTypes\*(C'\fR functions will look for the \fI.media.types\fR and
615 \&\fI.mime.types\fR files relative to you home directory.
616 .IP "http_proxy" 4
617 .IX Item "http_proxy"
618 .PD 0
619 .IP "ftp_proxy" 4
620 .IX Item "ftp_proxy"
621 .IP "xxx_proxy" 4
622 .IX Item "xxx_proxy"
623 .IP "no_proxy" 4
624 .IX Item "no_proxy"
625 .PD
626 These environment variables can be set to enable communication through
627 a proxy server.  See the description of the \f(CW\*(C`env_proxy\*(C'\fR method in
628 LWP::UserAgent.
629 .IP "\s-1PERL_LWP_USE_HTTP_10\s0" 4
630 .IX Item "PERL_LWP_USE_HTTP_10"
631 Enable the old \s-1HTTP/1\s0.0 protocol driver instead of the new \s-1HTTP/1\s0.1
632 driver.  You might want to set this to a \s-1TRUE\s0 value if you discover
633 that your old \s-1LWP\s0 applications fails after you installed \s-1LWP\-5\s0.60 or
634 better.
635 .IP "\s-1PERL_HTTP_URI_CLASS\s0" 4
636 .IX Item "PERL_HTTP_URI_CLASS"
637 Used to decide what \s-1URI\s0 objects to instantiate.  The default is \f(CW\*(C`URI\*(C'\fR.
638 You might want to set it to \f(CW\*(C`URI::URL\*(C'\fR for compatibility with old times.
639 .SH "AUTHORS"
640 .IX Header "AUTHORS"
641 \&\s-1LWP\s0 was made possible by contributions from Adam Newby, Albert
642 Dvornik, Alexandre Duret\-Lutz, Andreas Gustafsson, Andreas König,
643 Andrew Pimlott, Andy Lester, Ben Coleman, Benjamin Low, Ben Low, Ben
644 Tilly, Blair Zajac, Bob Dalgleish, BooK, Brad Hughes, Brian
645 J. Murrell, Brian McCauley, Charles C. Fu, Charles Lane, Chris Nandor,
646 Christian Gilmore, Chris W. Unger, Craig Macdonald, Dale Couch, Dan
647 Kubb, Dave Dunkin, Dave W. Smith, David Coppit, David Dick, David
648 D. Kilzer, Doug MacEachern, Edward Avis, erik, Gary Shea, Gisle Aas,
649 Graham Barr, Gurusamy Sarathy, Hans de Graaff, Harald Joerg, Harry
650 Bochner, Hugo, Ilya Zakharevich, \s-1INOUE\s0 Yoshinari, Ivan Panchenko, Jack
651 Shirazi, James Tillman, Jan Dubois, Jared Rhine, Jim Stern, Joao
652 Lopes, John Klar, Johnny Lee, Josh Kronengold, Josh Rai, Joshua
653 Chamas, Joshua Hoblitt, Kartik Subbarao, Keiichiro Nagano, Ken
654 Williams, \s-1KONISHI\s0 Katsuhiro, Lee T Lindley, Liam Quinn, Marc Hedlund,
655 Marc Langheinrich, Mark D. Anderson, Marko Asplund, Mark Stosberg,
656 Markus B Krüger, Markus Laker, Martijn Koster, Martin Thurn, Matthew
657 Eldridge, Matthew.van.Eerde, Matt Sergeant, Michael A. Chase, Michael
658 Quaranta, Michael Thompson, Mike Schilli, Moshe Kaminsky, Nathan
659 Torkington, Nicolai Langfeldt, Norton Allen, Olly Betts, Paul
660 J. Schinder, peterm, Philip GuentherDaniel Buenzli, Pon Hwa Lin,
661 Radoslaw Zielinski, Radu Greab, Randal L. Schwartz, Richard Chen,
662 Robin Barker, Roy Fielding, Sander van Zoest, Sean M. Burke,
663 shildreth, Slaven Rezic, Steve A Fink, Steve Hay, Steven Butler,
664 Steve_Kilbane, Takanori Ugai, Thomas Lotterer, Tim Bunce, Tom Hughes,
665 Tony Finch, Ville Skyttä, Ward Vandewege, William York, Yale Huang,
666 and Yitzchak Scott\-Thoennes.
667 .PP
668 \&\s-1LWP\s0 owes a lot in motivation, design, and code, to the libwww-perl
669 library for Perl4 by Roy Fielding, which included work from Alberto
670 Accomazzi, James Casey, Brooks Cutter, Martijn Koster, Oscar
671 Nierstrasz, Mel Melchner, Gertjan van Oosten, Jared Rhine, Jack
672 Shirazi, Gene Spafford, Marc VanHeyningen, Steven E. Brenner, Marion
673 Hakanson, Waldemar Kebsch, Tony Sanders, and Larry Wall; see the
674 libwww\-perl\-0.40 library for details.
675 .SH "COPYRIGHT"
676 .IX Header "COPYRIGHT"
677 .Vb 2
678 \&  Copyright 1995\-2009, Gisle Aas
679 \&  Copyright 1995, Martijn Koster
680 .Ve
681 .PP
682 This library is free software; you can redistribute it and/or
683 modify it under the same terms as Perl itself.
684 .SH "AVAILABILITY"
685 .IX Header "AVAILABILITY"
686 The latest version of this library is likely to be available from \s-1CPAN\s0
687 as well as:
688 .PP
689 .Vb 1
690 \&  http://gitorious.org/projects/libwww\-perl
691 .Ve
692 .PP
693 The best place to discuss this code is on the <libwww@perl.org>
694 mailing list.