Add built local::lib
[catagits/Gitalist.git] / local-lib5 / man / man3 / LWP::UserAgent.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::UserAgent 3"
132 .TH LWP::UserAgent 3 "2009-11-21" "perl v5.8.7" "User Contributed Perl Documentation"
133 .SH "NAME"
134 LWP::UserAgent \- Web user agent class
135 .SH "SYNOPSIS"
136 .IX Header "SYNOPSIS"
137 .Vb 1
138 \& require LWP::UserAgent;
139 .Ve
140 .PP
141 .Vb 3
142 \& my $ua = LWP::UserAgent\->new;
143 \& $ua\->timeout(10);
144 \& $ua\->env_proxy;
145 .Ve
146 .PP
147 .Vb 1
148 \& my $response = $ua\->get('http://search.cpan.org/');
149 .Ve
150 .PP
151 .Vb 6
152 \& if ($response\->is_success) {
153 \&     print $response\->decoded_content;  # or whatever
154 \& }
155 \& else {
156 \&     die $response\->status_line;
157 \& }
158 .Ve
159 .SH "DESCRIPTION"
160 .IX Header "DESCRIPTION"
161 The \f(CW\*(C`LWP::UserAgent\*(C'\fR is a class implementing a web user agent.
162 \&\f(CW\*(C`LWP::UserAgent\*(C'\fR objects can be used to dispatch web requests.
163 .PP
164 In normal use the application creates an \f(CW\*(C`LWP::UserAgent\*(C'\fR object, and
165 then configures it with values for timeouts, proxies, name, etc. It
166 then creates an instance of \f(CW\*(C`HTTP::Request\*(C'\fR for the request that
167 needs to be performed. This request is then passed to one of the
168 request method the UserAgent, which dispatches it using the relevant
169 protocol, and returns a \f(CW\*(C`HTTP::Response\*(C'\fR object.  There are
170 convenience methods for sending the most common request types: \fIget()\fR,
171 \&\fIhead()\fR and \fIpost()\fR.  When using these methods then the creation of the
172 request object is hidden as shown in the synopsis above.
173 .PP
174 The basic approach of the library is to use \s-1HTTP\s0 style communication
175 for all protocol schemes.  This means that you will construct
176 \&\f(CW\*(C`HTTP::Request\*(C'\fR objects and receive \f(CW\*(C`HTTP::Response\*(C'\fR objects even
177 for non-HTTP resources like \fIgopher\fR and \fIftp\fR.  In order to achieve
178 even more similarity to \s-1HTTP\s0 style communications, gopher menus and
179 file directories are converted to \s-1HTML\s0 documents.
180 .SH "CONSTRUCTOR METHODS"
181 .IX Header "CONSTRUCTOR METHODS"
182 The following constructor methods are available:
183 .ie n .IP "$ua = LWP::UserAgent\->new( %options )" 4
184 .el .IP "$ua = LWP::UserAgent\->new( \f(CW%options\fR )" 4
185 .IX Item "$ua = LWP::UserAgent->new( %options )"
186 This method constructs a new \f(CW\*(C`LWP::UserAgent\*(C'\fR object and returns it.
187 Key/value pair arguments may be provided to set up the initial state.
188 The following options correspond to attribute methods described below:
189 .Sp
190 .Vb 15
191 \&   KEY                     DEFAULT
192 \&   \-\-\-\-\-\-\-\-\-\-\-             \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
193 \&   agent                   "libwww\-perl/#.###"
194 \&   from                    undef
195 \&   conn_cache              undef
196 \&   cookie_jar              undef
197 \&   default_headers         HTTP::Headers\->new
198 \&   local_address           undef
199 \&   max_size                undef
200 \&   max_redirect            7
201 \&   parse_head              1
202 \&   protocols_allowed       undef
203 \&   protocols_forbidden     undef
204 \&   requests_redirectable   ['GET', 'HEAD']
205 \&   timeout                 180
206 .Ve
207 .Sp
208 The following additional options are also accepted: If the
209 \&\f(CW\*(C`env_proxy\*(C'\fR option is passed in with a \s-1TRUE\s0 value, then proxy
210 settings are read from environment variables (see \fIenv_proxy()\fR method
211 below).  If the \f(CW\*(C`keep_alive\*(C'\fR option is passed in, then a
212 \&\f(CW\*(C`LWP::ConnCache\*(C'\fR is set up (see \fIconn_cache()\fR method below).  The
213 \&\f(CW\*(C`keep_alive\*(C'\fR value is passed on as the \f(CW\*(C`total_capacity\*(C'\fR for the
214 connection cache.
215 .IP "$ua\->clone" 4
216 .IX Item "$ua->clone"
217 Returns a copy of the LWP::UserAgent object.
218 .SH "ATTRIBUTES"
219 .IX Header "ATTRIBUTES"
220 The settings of the configuration attributes modify the behaviour of the
221 \&\f(CW\*(C`LWP::UserAgent\*(C'\fR when it dispatches requests.  Most of these can also
222 be initialized by options passed to the constructor method.
223 .PP
224 The following attribute methods are provided.  The attribute value is
225 left unchanged if no argument is given.  The return value from each
226 method is the old attribute value.
227 .IP "$ua\->agent" 4
228 .IX Item "$ua->agent"
229 .PD 0
230 .ie n .IP "$ua\->agent( $product_id )" 4
231 .el .IP "$ua\->agent( \f(CW$product_id\fR )" 4
232 .IX Item "$ua->agent( $product_id )"
233 .PD
234 Get/set the product token that is used to identify the user agent on
235 the network.  The agent value is sent as the \*(L"User\-Agent\*(R" header in
236 the requests.  The default is the string returned by the \fI_agent()\fR
237 method (see below).
238 .Sp
239 If the \f(CW$product_id\fR ends with space then the \fI_agent()\fR string is
240 appended to it.
241 .Sp
242 The user agent string should be one or more simple product identifiers
243 with an optional version number separated by the \*(L"/\*(R" character.
244 Examples are:
245 .Sp
246 .Vb 4
247 \&  $ua\->agent('Checkbot/0.4 ' . $ua\->_agent);
248 \&  $ua\->agent('Checkbot/0.4 ');    # same as above
249 \&  $ua\->agent('Mozilla/5.0');
250 \&  $ua\->agent("");                 # don't identify
251 .Ve
252 .IP "$ua\->_agent" 4
253 .IX Item "$ua->_agent"
254 Returns the default agent identifier.  This is a string of the form
255 \&\*(L"libwww\-perl/#.###\*(R", where \*(L"#.###\*(R" is substituted with the version number
256 of this library.
257 .IP "$ua\->from" 4
258 .IX Item "$ua->from"
259 .PD 0
260 .ie n .IP "$ua\->from( $email_address )" 4
261 .el .IP "$ua\->from( \f(CW$email_address\fR )" 4
262 .IX Item "$ua->from( $email_address )"
263 .PD
264 Get/set the e\-mail address for the human user who controls
265 the requesting user agent.  The address should be machine\-usable, as
266 defined in \s-1RFC\s0 822.  The \f(CW\*(C`from\*(C'\fR value is send as the \*(L"From\*(R" header in
267 the requests.  Example:
268 .Sp
269 .Vb 1
270 \&  $ua\->from('gaas@cpan.org');
271 .Ve
272 .Sp
273 The default is to not send a \*(L"From\*(R" header.  See the \fIdefault_headers()\fR
274 method for the more general interface that allow any header to be defaulted.
275 .IP "$ua\->cookie_jar" 4
276 .IX Item "$ua->cookie_jar"
277 .PD 0
278 .ie n .IP "$ua\->cookie_jar( $cookie_jar_obj )" 4
279 .el .IP "$ua\->cookie_jar( \f(CW$cookie_jar_obj\fR )" 4
280 .IX Item "$ua->cookie_jar( $cookie_jar_obj )"
281 .PD
282 Get/set the cookie jar object to use.  The only requirement is that
283 the cookie jar object must implement the extract_cookies($request) and
284 add_cookie_header($response) methods.  These methods will then be
285 invoked by the user agent as requests are sent and responses are
286 received.  Normally this will be a \f(CW\*(C`HTTP::Cookies\*(C'\fR object or some
287 subclass.
288 .Sp
289 The default is to have no cookie_jar, i.e. never automatically add
290 \&\*(L"Cookie\*(R" headers to the requests.
291 .Sp
292 Shortcut: If a reference to a plain hash is passed in as the
293 \&\f(CW$cookie_jar_object\fR, then it is replaced with an instance of
294 \&\f(CW\*(C`HTTP::Cookies\*(C'\fR that is initialized based on the hash.  This form also
295 automatically loads the \f(CW\*(C`HTTP::Cookies\*(C'\fR module.  It means that:
296 .Sp
297 .Vb 1
298 \&  $ua\->cookie_jar({ file => "$ENV{HOME}/.cookies.txt" });
299 .Ve
300 .Sp
301 is really just a shortcut for:
302 .Sp
303 .Vb 2
304 \&  require HTTP::Cookies;
305 \&  $ua\->cookie_jar(HTTP::Cookies\->new(file => "$ENV{HOME}/.cookies.txt"));
306 .Ve
307 .IP "$ua\->default_headers" 4
308 .IX Item "$ua->default_headers"
309 .PD 0
310 .ie n .IP "$ua\->default_headers( $headers_obj )" 4
311 .el .IP "$ua\->default_headers( \f(CW$headers_obj\fR )" 4
312 .IX Item "$ua->default_headers( $headers_obj )"
313 .PD
314 Get/set the headers object that will provide default header values for
315 any requests sent.  By default this will be an empty \f(CW\*(C`HTTP::Headers\*(C'\fR
316 object.
317 .ie n .IP "$ua\->default_header( $field )" 4
318 .el .IP "$ua\->default_header( \f(CW$field\fR )" 4
319 .IX Item "$ua->default_header( $field )"
320 .PD 0
321 .ie n .IP "$ua\->default_header( $field\fR => \f(CW$value )" 4
322 .el .IP "$ua\->default_header( \f(CW$field\fR => \f(CW$value\fR )" 4
323 .IX Item "$ua->default_header( $field => $value )"
324 .PD
325 This is just a short-cut for \f(CW$ua\fR\->default_headers\->header( \f(CW$field\fR =>
326 \&\f(CW$value\fR ). Example:
327 .Sp
328 .Vb 2
329 \&  $ua\->default_header('Accept\-Encoding' => scalar HTTP::Message::decodable());
330 \&  $ua\->default_header('Accept\-Language' => "no, en");
331 .Ve
332 .IP "$ua\->conn_cache" 4
333 .IX Item "$ua->conn_cache"
334 .PD 0
335 .ie n .IP "$ua\->conn_cache( $cache_obj )" 4
336 .el .IP "$ua\->conn_cache( \f(CW$cache_obj\fR )" 4
337 .IX Item "$ua->conn_cache( $cache_obj )"
338 .PD
339 Get/set the \f(CW\*(C`LWP::ConnCache\*(C'\fR object to use.  See LWP::ConnCache
340 for details.
341 .ie n .IP "$ua\->credentials( $netloc\fR, \f(CW$realm )" 4
342 .el .IP "$ua\->credentials( \f(CW$netloc\fR, \f(CW$realm\fR )" 4
343 .IX Item "$ua->credentials( $netloc, $realm )"
344 .PD 0
345 .ie n .IP "$ua\->credentials( $netloc\fR, \f(CW$realm\fR, \f(CW$uname\fR, \f(CW$pass )" 4
346 .el .IP "$ua\->credentials( \f(CW$netloc\fR, \f(CW$realm\fR, \f(CW$uname\fR, \f(CW$pass\fR )" 4
347 .IX Item "$ua->credentials( $netloc, $realm, $uname, $pass )"
348 .PD
349 Get/set the user name and password to be used for a realm.
350 .Sp
351 The \f(CW$netloc\fR is a string of the form \*(L"<host>:<port>\*(R".  The username and
352 password will only be passed to this server.  Example:
353 .Sp
354 .Vb 1
355 \&  $ua\->credentials("www.example.com:80", "Some Realm", "foo", "secret");
356 .Ve
357 .IP "$ua\->local_address" 4
358 .IX Item "$ua->local_address"
359 .PD 0
360 .ie n .IP "$ua\->local_address( $address )" 4
361 .el .IP "$ua\->local_address( \f(CW$address\fR )" 4
362 .IX Item "$ua->local_address( $address )"
363 .PD
364 Get/set the local interface to bind to for network connections.  The interface
365 can be specified as a hostname or an \s-1IP\s0 address.  This value is passed as the
366 \&\f(CW\*(C`LocalAddr\*(C'\fR argument to IO::Socket::INET.
367 .IP "$ua\->max_size" 4
368 .IX Item "$ua->max_size"
369 .PD 0
370 .ie n .IP "$ua\->max_size( $bytes )" 4
371 .el .IP "$ua\->max_size( \f(CW$bytes\fR )" 4
372 .IX Item "$ua->max_size( $bytes )"
373 .PD
374 Get/set the size limit for response content.  The default is \f(CW\*(C`undef\*(C'\fR,
375 which means that there is no limit.  If the returned response content
376 is only partial, because the size limit was exceeded, then a
377 \&\*(L"Client\-Aborted\*(R" header will be added to the response.  The content
378 might end up longer than \f(CW\*(C`max_size\*(C'\fR as we abort once appending a
379 chunk of data makes the length exceed the limit.  The \*(L"Content\-Length\*(R"
380 header, if present, will indicate the length of the full content and
381 will normally not be the same as \f(CW\*(C`length($res\->content)\*(C'\fR.
382 .IP "$ua\->max_redirect" 4
383 .IX Item "$ua->max_redirect"
384 .PD 0
385 .ie n .IP "$ua\->max_redirect( $n )" 4
386 .el .IP "$ua\->max_redirect( \f(CW$n\fR )" 4
387 .IX Item "$ua->max_redirect( $n )"
388 .PD
389 This reads or sets the object's limit of how many times it will obey
390 redirection responses in a given request cycle.
391 .Sp
392 By default, the value is 7. This means that if you call \fIrequest()\fR
393 method and the response is a redirect elsewhere which is in turn a
394 redirect, and so on seven times, then \s-1LWP\s0 gives up after that seventh
395 request.
396 .IP "$ua\->parse_head" 4
397 .IX Item "$ua->parse_head"
398 .PD 0
399 .ie n .IP "$ua\->parse_head( $boolean )" 4
400 .el .IP "$ua\->parse_head( \f(CW$boolean\fR )" 4
401 .IX Item "$ua->parse_head( $boolean )"
402 .PD
403 Get/set a value indicating whether we should initialize response
404 headers from the <head> section of \s-1HTML\s0 documents. The default is
405 \&\s-1TRUE\s0.  Do not turn this off, unless you know what you are doing.
406 .IP "$ua\->protocols_allowed" 4
407 .IX Item "$ua->protocols_allowed"
408 .PD 0
409 .IP "$ua\->protocols_allowed( \e@protocols )" 4
410 .IX Item "$ua->protocols_allowed( @protocols )"
411 .PD
412 This reads (or sets) this user agent's list of protocols that the
413 request methods will exclusively allow.  The protocol names are case
414 insensitive.
415 .Sp
416 For example: \f(CW\*(C`$ua\->protocols_allowed( [ 'http', 'https'] );\*(C'\fR
417 means that this user agent will \fIallow only\fR those protocols,
418 and attempts to use this user agent to access URLs with any other
419 schemes (like \*(L"ftp://...\*(R") will result in a 500 error.
420 .Sp
421 To delete the list, call: \f(CW\*(C`$ua\->protocols_allowed(undef)\*(C'\fR
422 .Sp
423 By default, an object has neither a \f(CW\*(C`protocols_allowed\*(C'\fR list, nor a
424 \&\f(CW\*(C`protocols_forbidden\*(C'\fR list.
425 .Sp
426 Note that having a \f(CW\*(C`protocols_allowed\*(C'\fR list causes any
427 \&\f(CW\*(C`protocols_forbidden\*(C'\fR list to be ignored.
428 .IP "$ua\->protocols_forbidden" 4
429 .IX Item "$ua->protocols_forbidden"
430 .PD 0
431 .IP "$ua\->protocols_forbidden( \e@protocols )" 4
432 .IX Item "$ua->protocols_forbidden( @protocols )"
433 .PD
434 This reads (or sets) this user agent's list of protocols that the
435 request method will \fInot\fR allow. The protocol names are case
436 insensitive.
437 .Sp
438 For example: \f(CW\*(C`$ua\->protocols_forbidden( [ 'file', 'mailto'] );\*(C'\fR
439 means that this user agent will \fInot\fR allow those protocols, and
440 attempts to use this user agent to access URLs with those schemes
441 will result in a 500 error.
442 .Sp
443 To delete the list, call: \f(CW\*(C`$ua\->protocols_forbidden(undef)\*(C'\fR
444 .IP "$ua\->requests_redirectable" 4
445 .IX Item "$ua->requests_redirectable"
446 .PD 0
447 .IP "$ua\->requests_redirectable( \e@requests )" 4
448 .IX Item "$ua->requests_redirectable( @requests )"
449 .PD
450 This reads or sets the object's list of request names that
451 \&\f(CW\*(C`$ua\->redirect_ok(...)\*(C'\fR will allow redirection for.  By
452 default, this is \f(CW\*(C`['GET', 'HEAD']\*(C'\fR, as per \s-1RFC\s0 2616.  To
453 change to include '\s-1POST\s0', consider:
454 .Sp
455 .Vb 1
456 \&   push @{ $ua\->requests_redirectable }, 'POST';
457 .Ve
458 .IP "$ua\->show_progress" 4
459 .IX Item "$ua->show_progress"
460 .PD 0
461 .ie n .IP "$ua\->show_progress( $boolean )" 4
462 .el .IP "$ua\->show_progress( \f(CW$boolean\fR )" 4
463 .IX Item "$ua->show_progress( $boolean )"
464 .PD
465 Get/set a value indicating whether a progress bar should be displayed
466 on on the terminal as requests are processed. The default is \s-1FALSE\s0.
467 .IP "$ua\->timeout" 4
468 .IX Item "$ua->timeout"
469 .PD 0
470 .ie n .IP "$ua\->timeout( $secs )" 4
471 .el .IP "$ua\->timeout( \f(CW$secs\fR )" 4
472 .IX Item "$ua->timeout( $secs )"
473 .PD
474 Get/set the timeout value in seconds. The default \fItimeout()\fR value is
475 180 seconds, i.e. 3 minutes.
476 .Sp
477 The requests is aborted if no activity on the connection to the server
478 is observed for \f(CW\*(C`timeout\*(C'\fR seconds.  This means that the time it takes
479 for the complete transaction and the \fIrequest()\fR method to actually
480 return might be longer.
481 .Sh "Proxy attributes"
482 .IX Subsection "Proxy attributes"
483 The following methods set up when requests should be passed via a
484 proxy server.
485 .ie n .IP "$ua\->proxy(\e@schemes, $proxy_url)" 4
486 .el .IP "$ua\->proxy(\e@schemes, \f(CW$proxy_url\fR)" 4
487 .IX Item "$ua->proxy(@schemes, $proxy_url)"
488 .PD 0
489 .ie n .IP "$ua\->proxy($scheme, $proxy_url)" 4
490 .el .IP "$ua\->proxy($scheme, \f(CW$proxy_url\fR)" 4
491 .IX Item "$ua->proxy($scheme, $proxy_url)"
492 .PD
493 Set/retrieve proxy \s-1URL\s0 for a scheme:
494 .Sp
495 .Vb 2
496 \& $ua\->proxy(['http', 'ftp'], 'http://proxy.sn.no:8001/');
497 \& $ua\->proxy('gopher', 'http://proxy.sn.no:8001/');
498 .Ve
499 .Sp
500 The first form specifies that the \s-1URL\s0 is to be used for proxying of
501 access methods listed in the list in the first method argument,
502 i.e. 'http' and 'ftp'.
503 .Sp
504 The second form shows a shorthand form for specifying
505 proxy \s-1URL\s0 for a single access scheme.
506 .ie n .IP "$ua\->no_proxy( $domain, ... )" 4
507 .el .IP "$ua\->no_proxy( \f(CW$domain\fR, ... )" 4
508 .IX Item "$ua->no_proxy( $domain, ... )"
509 Do not proxy requests to the given domains.  Calling no_proxy without
510 any domains clears the list of domains. Eg:
511 .Sp
512 .Vb 1
513 \& $ua\->no_proxy('localhost', 'example.com');
514 .Ve
515 .IP "$ua\->env_proxy" 4
516 .IX Item "$ua->env_proxy"
517 Load proxy settings from *_proxy environment variables.  You might
518 specify proxies like this (sh\-syntax):
519 .Sp
520 .Vb 4
521 \&  gopher_proxy=http://proxy.my.place/
522 \&  wais_proxy=http://proxy.my.place/
523 \&  no_proxy="localhost,example.com"
524 \&  export gopher_proxy wais_proxy no_proxy
525 .Ve
526 .Sp
527 csh or tcsh users should use the \f(CW\*(C`setenv\*(C'\fR command to define these
528 environment variables.
529 .Sp
530 On systems with case insensitive environment variables there exists a
531 name clash between the \s-1CGI\s0 environment variables and the \f(CW\*(C`HTTP_PROXY\*(C'\fR
532 environment variable normally picked up by \fIenv_proxy()\fR.  Because of
533 this \f(CW\*(C`HTTP_PROXY\*(C'\fR is not honored for \s-1CGI\s0 scripts.  The
534 \&\f(CW\*(C`CGI_HTTP_PROXY\*(C'\fR environment variable can be used instead.
535 .Sh "Handlers"
536 .IX Subsection "Handlers"
537 Handlers are code that injected at various phases during the
538 processing of requests.  The following methods are provided to manage
539 the active handlers:
540 .ie n .IP "$ua\->add_handler( $phase\fR => \e&cb, \f(CW%matchspec )" 4
541 .el .IP "$ua\->add_handler( \f(CW$phase\fR => \e&cb, \f(CW%matchspec\fR )" 4
542 .IX Item "$ua->add_handler( $phase => &cb, %matchspec )"
543 Add handler to be invoked in the given processing phase.  For how to
544 specify \f(CW%matchspec\fR see \*(L"Matching\*(R" in HTTP::Config.
545 .Sp
546 The possible values \f(CW$phase\fR and the corresponding callback signatures are:
547 .RS 4
548 .ie n .IP "request_preprepare => sub { my($request, $ua\fR, \f(CW$h\fR) = \f(CW@_; ... }" 4
549 .el .IP "request_preprepare => sub { my($request, \f(CW$ua\fR, \f(CW$h\fR) = \f(CW@_\fR; ... }" 4
550 .IX Item "request_preprepare => sub { my($request, $ua, $h) = @_; ... }"
551 The handler is called before the \f(CW\*(C`request_prepare\*(C'\fR and other standard
552 initialization of of the request.  This can be used to set up headers
553 and attributes that the \f(CW\*(C`request_prepare\*(C'\fR handler depends on.  Proxy
554 initialization should take place here; but in general don't register
555 handlers for this phase.
556 .ie n .IP "request_prepare => sub { my($request, $ua\fR, \f(CW$h\fR) = \f(CW@_; ... }" 4
557 .el .IP "request_prepare => sub { my($request, \f(CW$ua\fR, \f(CW$h\fR) = \f(CW@_\fR; ... }" 4
558 .IX Item "request_prepare => sub { my($request, $ua, $h) = @_; ... }"
559 The handler is called before the request is sent and can modify the
560 request any way it see fit.  This can for instance be used to add
561 certain headers to specific requests.
562 .Sp
563 The method can assign a new request object to \f(CW$_\fR[0] to replace the
564 request that is sent fully.
565 .Sp
566 The return value from the callback is ignored.  If an exceptions is
567 raised it will abort the request and make the request method return a
568 \&\*(L"400 Bad request\*(R" response.
569 .ie n .IP "request_send => sub { my($request, $ua\fR, \f(CW$h\fR) = \f(CW@_; ... }" 4
570 .el .IP "request_send => sub { my($request, \f(CW$ua\fR, \f(CW$h\fR) = \f(CW@_\fR; ... }" 4
571 .IX Item "request_send => sub { my($request, $ua, $h) = @_; ... }"
572 This handler get a chance of handling requests before it's sent to the
573 protocol handlers.  It should return an HTTP::Response object if it
574 wishes to terminate the processing; otherwise it should return nothing.
575 .Sp
576 The \f(CW\*(C`response_header\*(C'\fR and \f(CW\*(C`response_data\*(C'\fR handlers will not be
577 invoked for this response, but the \f(CW\*(C`response_done\*(C'\fR will be.
578 .ie n .IP "response_header => sub { my($response, $ua\fR, \f(CW$h\fR) = \f(CW@_; ... }" 4
579 .el .IP "response_header => sub { my($response, \f(CW$ua\fR, \f(CW$h\fR) = \f(CW@_\fR; ... }" 4
580 .IX Item "response_header => sub { my($response, $ua, $h) = @_; ... }"
581 This handler is called right after the response headers have been
582 received, but before any content data.  The handler might set up
583 handlers for data and might croak to abort the request.
584 .Sp
585 The handler might set the \f(CW$response\fR\->{default_add_content} value to
586 control if any received data should be added to the response object
587 directly.  This will initially be false if the \f(CW$ua\fR\->\fIrequest()\fR method
588 was called with a ':content_filename' or ':content_callbak' argument;
589 otherwise true.
590 .ie n .IP "response_data => sub { my($response, $ua\fR, \f(CW$h\fR, \f(CW$data\fR) = \f(CW@_; ... }" 4
591 .el .IP "response_data => sub { my($response, \f(CW$ua\fR, \f(CW$h\fR, \f(CW$data\fR) = \f(CW@_\fR; ... }" 4
592 .IX Item "response_data => sub { my($response, $ua, $h, $data) = @_; ... }"
593 This handlers is called for each chunk of data received for the
594 response.  The handler might croak to abort the request.
595 .Sp
596 This handler need to return a \s-1TRUE\s0 value to be called again for
597 subsequent chunks for the same request.
598 .ie n .IP "response_done => sub { my($response, $ua\fR, \f(CW$h\fR) = \f(CW@_; ... }" 4
599 .el .IP "response_done => sub { my($response, \f(CW$ua\fR, \f(CW$h\fR) = \f(CW@_\fR; ... }" 4
600 .IX Item "response_done => sub { my($response, $ua, $h) = @_; ... }"
601 The handler is called after the response has been fully received, but
602 before any redirect handling is attempted.  The handler can be used to
603 extract information or modify the response.
604 .ie n .IP "response_redirect => sub { my($response, $ua\fR, \f(CW$h\fR) = \f(CW@_; ... }" 4
605 .el .IP "response_redirect => sub { my($response, \f(CW$ua\fR, \f(CW$h\fR) = \f(CW@_\fR; ... }" 4
606 .IX Item "response_redirect => sub { my($response, $ua, $h) = @_; ... }"
607 The handler is called in \f(CW$ua\fR\->request after \f(CW\*(C`response_done\*(C'\fR.  If the
608 handler return an HTTP::Request object we'll start over with processing
609 this request instead.
610 .RE
611 .RS 4
612 .RE
613 .ie n .IP "$ua\->remove_handler( undef, %matchspec )" 4
614 .el .IP "$ua\->remove_handler( undef, \f(CW%matchspec\fR )" 4
615 .IX Item "$ua->remove_handler( undef, %matchspec )"
616 .PD 0
617 .ie n .IP "$ua\->remove_handler( $phase\fR, \f(CW%matchspec )" 4
618 .el .IP "$ua\->remove_handler( \f(CW$phase\fR, \f(CW%matchspec\fR )" 4
619 .IX Item "$ua->remove_handler( $phase, %matchspec )"
620 .PD
621 Remove handlers that match the given \f(CW%matchspec\fR.  If \f(CW$phase\fR is not
622 provided remove handlers from all phases.
623 .Sp
624 Be careful as calling this function with \f(CW%matchspec\fR that is not not
625 specific enough can remove handlers not owned by you.  It's probably
626 better to use the \fIset_my_handler()\fR method instead.
627 .Sp
628 The removed handlers are returned.
629 .ie n .IP "$ua\->set_my_handler( $phase\fR, \f(CW$cb\fR, \f(CW%matchspec )" 4
630 .el .IP "$ua\->set_my_handler( \f(CW$phase\fR, \f(CW$cb\fR, \f(CW%matchspec\fR )" 4
631 .IX Item "$ua->set_my_handler( $phase, $cb, %matchspec )"
632 Set handlers private to the executing subroutine.  Works by defaulting
633 an \f(CW\*(C`owner\*(C'\fR field to the \f(CW%matchhspec\fR that holds the name of the called
634 subroutine.  You might pass an explicit \f(CW\*(C`owner\*(C'\fR to override this.
635 .Sp
636 If \f(CW$cb\fR is passed as \f(CW\*(C`undef\*(C'\fR, remove the handler.
637 .ie n .IP "$ua\->get_my_handler( $phase\fR, \f(CW%matchspec )" 4
638 .el .IP "$ua\->get_my_handler( \f(CW$phase\fR, \f(CW%matchspec\fR )" 4
639 .IX Item "$ua->get_my_handler( $phase, %matchspec )"
640 .PD 0
641 .ie n .IP "$ua\->get_my_handler( $phase\fR, \f(CW%matchspec\fR, \f(CW$init )" 4
642 .el .IP "$ua\->get_my_handler( \f(CW$phase\fR, \f(CW%matchspec\fR, \f(CW$init\fR )" 4
643 .IX Item "$ua->get_my_handler( $phase, %matchspec, $init )"
644 .PD
645 Will retrieve the matching handler as hash ref.
646 .Sp
647 If \f(CW$init\fR is passed passed as a \s-1TRUE\s0 value, create and add the
648 handler if it's not found.  If \f(CW$init\fR is a subroutine reference, then
649 it's called with the created handler hash as argument.  This sub might
650 populate the hash with extra fields; especially the callback.  If
651 \&\f(CW$init\fR is a hash reference, merge the hashes.
652 .ie n .IP "$ua\->handlers( $phase\fR, \f(CW$request )" 4
653 .el .IP "$ua\->handlers( \f(CW$phase\fR, \f(CW$request\fR )" 4
654 .IX Item "$ua->handlers( $phase, $request )"
655 .PD 0
656 .ie n .IP "$ua\->handlers( $phase\fR, \f(CW$response )" 4
657 .el .IP "$ua\->handlers( \f(CW$phase\fR, \f(CW$response\fR )" 4
658 .IX Item "$ua->handlers( $phase, $response )"
659 .PD
660 Returns the handlers that apply to the given request or response at
661 the given processing phase.
662 .SH "REQUEST METHODS"
663 .IX Header "REQUEST METHODS"
664 The methods described in this section are used to dispatch requests
665 via the user agent.  The following request methods are provided:
666 .ie n .IP "$ua\->get( $url )" 4
667 .el .IP "$ua\->get( \f(CW$url\fR )" 4
668 .IX Item "$ua->get( $url )"
669 .PD 0
670 .ie n .IP "$ua\->get( $url\fR , \f(CW$field_name\fR => \f(CW$value, ... )" 4
671 .el .IP "$ua\->get( \f(CW$url\fR , \f(CW$field_name\fR => \f(CW$value\fR, ... )" 4
672 .IX Item "$ua->get( $url , $field_name => $value, ... )"
673 .PD
674 This method will dispatch a \f(CW\*(C`GET\*(C'\fR request on the given \f(CW$url\fR.  Further
675 arguments can be given to initialize the headers of the request. These
676 are given as separate name/value pairs.  The return value is a
677 response object.  See HTTP::Response for a description of the
678 interface it provides.
679 .Sp
680 There will still be a response object returned when \s-1LWP\s0 can't connect to the
681 server specified in the \s-1URL\s0 or when other failures in protocol handlers occur.
682 These internal responses use the standard \s-1HTTP\s0 status codes, so the responses
683 can't be differentiated by testing the response status code alone.  Error
684 responses that \s-1LWP\s0 generates internally will have the \*(L"Client\-Warning\*(R" header
685 set to the value \*(L"Internal response\*(R".  If you need to differentiate these
686 internal responses from responses that a remote server actually generates, you
687 need to test this header value.
688 .Sp
689 Fields names that start with \*(L":\*(R" are special.  These will not
690 initialize headers of the request but will determine how the response
691 content is treated.  The following special field names are recognized:
692 .Sp
693 .Vb 3
694 \&    :content_file   => $filename
695 \&    :content_cb     => \e&callback
696 \&    :read_size_hint => $bytes
697 .Ve
698 .Sp
699 If a \f(CW$filename\fR is provided with the \f(CW\*(C`:content_file\*(C'\fR option, then the
700 response content will be saved here instead of in the response
701 object.  If a callback is provided with the \f(CW\*(C`:content_cb\*(C'\fR option then
702 this function will be called for each chunk of the response content as
703 it is received from the server.  If neither of these options are
704 given, then the response content will accumulate in the response
705 object itself.  This might not be suitable for very large response
706 bodies.  Only one of \f(CW\*(C`:content_file\*(C'\fR or \f(CW\*(C`:content_cb\*(C'\fR can be
707 specified.  The content of unsuccessful responses will always
708 accumulate in the response object itself, regardless of the
709 \&\f(CW\*(C`:content_file\*(C'\fR or \f(CW\*(C`:content_cb\*(C'\fR options passed in.
710 .Sp
711 The \f(CW\*(C`:read_size_hint\*(C'\fR option is passed to the protocol module which
712 will try to read data from the server in chunks of this size.  A
713 smaller value for the \f(CW\*(C`:read_size_hint\*(C'\fR will result in a higher
714 number of callback invocations.
715 .Sp
716 The callback function is called with 3 arguments: a chunk of data, a
717 reference to the response object, and a reference to the protocol
718 object.  The callback can abort the request by invoking \fIdie()\fR.  The
719 exception message will show up as the \*(L"X\-Died\*(R" header field in the
720 response returned by the \fIget()\fR function.
721 .ie n .IP "$ua\->head( $url )" 4
722 .el .IP "$ua\->head( \f(CW$url\fR )" 4
723 .IX Item "$ua->head( $url )"
724 .PD 0
725 .ie n .IP "$ua\->head( $url\fR , \f(CW$field_name\fR => \f(CW$value, ... )" 4
726 .el .IP "$ua\->head( \f(CW$url\fR , \f(CW$field_name\fR => \f(CW$value\fR, ... )" 4
727 .IX Item "$ua->head( $url , $field_name => $value, ... )"
728 .PD
729 This method will dispatch a \f(CW\*(C`HEAD\*(C'\fR request on the given \f(CW$url\fR.
730 Otherwise it works like the \fIget()\fR method described above.
731 .ie n .IP "$ua\->post( $url, \e%form )" 4
732 .el .IP "$ua\->post( \f(CW$url\fR, \e%form )" 4
733 .IX Item "$ua->post( $url, %form )"
734 .PD 0
735 .ie n .IP "$ua\->post( $url, \e@form )" 4
736 .el .IP "$ua\->post( \f(CW$url\fR, \e@form )" 4
737 .IX Item "$ua->post( $url, @form )"
738 .ie n .IP "$ua\->post( $url\fR, \e%form, \f(CW$field_name\fR => \f(CW$value, ... )" 4
739 .el .IP "$ua\->post( \f(CW$url\fR, \e%form, \f(CW$field_name\fR => \f(CW$value\fR, ... )" 4
740 .IX Item "$ua->post( $url, %form, $field_name => $value, ... )"
741 .ie n .IP "$ua\->post( $url\fR, \f(CW$field_name\fR => \f(CW$value,... Content => \e%form )" 4
742 .el .IP "$ua\->post( \f(CW$url\fR, \f(CW$field_name\fR => \f(CW$value\fR,... Content => \e%form )" 4
743 .IX Item "$ua->post( $url, $field_name => $value,... Content => %form )"
744 .ie n .IP "$ua\->post( $url\fR, \f(CW$field_name\fR => \f(CW$value,... Content => \e@form )" 4
745 .el .IP "$ua\->post( \f(CW$url\fR, \f(CW$field_name\fR => \f(CW$value\fR,... Content => \e@form )" 4
746 .IX Item "$ua->post( $url, $field_name => $value,... Content => @form )"
747 .ie n .IP "$ua\->post( $url\fR, \f(CW$field_name\fR => \f(CW$value\fR,... Content => \f(CW$content )" 4
748 .el .IP "$ua\->post( \f(CW$url\fR, \f(CW$field_name\fR => \f(CW$value\fR,... Content => \f(CW$content\fR )" 4
749 .IX Item "$ua->post( $url, $field_name => $value,... Content => $content )"
750 .PD
751 This method will dispatch a \f(CW\*(C`POST\*(C'\fR request on the given \f(CW$url\fR, with
752 \&\f(CW%form\fR or \f(CW@form\fR providing the key/value pairs for the fill-in form
753 content. Additional headers and content options are the same as for
754 the \fIget()\fR method.
755 .Sp
756 This method will use the \s-1\fIPOST\s0()\fR function from \f(CW\*(C`HTTP::Request::Common\*(C'\fR
757 to build the request.  See HTTP::Request::Common for a details on
758 how to pass form content and other advanced features.
759 .ie n .IP "$ua\->mirror( $url\fR, \f(CW$filename )" 4
760 .el .IP "$ua\->mirror( \f(CW$url\fR, \f(CW$filename\fR )" 4
761 .IX Item "$ua->mirror( $url, $filename )"
762 This method will get the document identified by \f(CW$url\fR and store it in
763 file called \f(CW$filename\fR.  If the file already exists, then the request
764 will contain an \*(L"If\-Modified\-Since\*(R" header matching the modification
765 time of the file.  If the document on the server has not changed since
766 this time, then nothing happens.  If the document has been updated, it
767 will be downloaded again.  The modification time of the file will be
768 forced to match that of the server.
769 .Sp
770 The return value is the the response object.
771 .ie n .IP "$ua\->request( $request )" 4
772 .el .IP "$ua\->request( \f(CW$request\fR )" 4
773 .IX Item "$ua->request( $request )"
774 .PD 0
775 .ie n .IP "$ua\->request( $request\fR, \f(CW$content_file )" 4
776 .el .IP "$ua\->request( \f(CW$request\fR, \f(CW$content_file\fR )" 4
777 .IX Item "$ua->request( $request, $content_file )"
778 .ie n .IP "$ua\->request( $request\fR, \f(CW$content_cb )" 4
779 .el .IP "$ua\->request( \f(CW$request\fR, \f(CW$content_cb\fR )" 4
780 .IX Item "$ua->request( $request, $content_cb )"
781 .ie n .IP "$ua\->request( $request\fR, \f(CW$content_cb\fR, \f(CW$read_size_hint )" 4
782 .el .IP "$ua\->request( \f(CW$request\fR, \f(CW$content_cb\fR, \f(CW$read_size_hint\fR )" 4
783 .IX Item "$ua->request( $request, $content_cb, $read_size_hint )"
784 .PD
785 This method will dispatch the given \f(CW$request\fR object.  Normally this
786 will be an instance of the \f(CW\*(C`HTTP::Request\*(C'\fR class, but any object with
787 a similar interface will do.  The return value is a response object.
788 See HTTP::Request and HTTP::Response for a description of the
789 interface provided by these classes.
790 .Sp
791 The \fIrequest()\fR method will process redirects and authentication
792 responses transparently.  This means that it may actually send several
793 simple requests via the \fIsimple_request()\fR method described below.
794 .Sp
795 The request methods described above; \fIget()\fR, \fIhead()\fR, \fIpost()\fR and
796 \&\fImirror()\fR, will all dispatch the request they build via this method.
797 They are convenience methods that simply hides the creation of the
798 request object for you.
799 .Sp
800 The \f(CW$content_file\fR, \f(CW$content_cb\fR and \f(CW$read_size_hint\fR all correspond to
801 options described with the \fIget()\fR method above.
802 .Sp
803 You are allowed to use a \s-1CODE\s0 reference as \f(CW\*(C`content\*(C'\fR in the request
804 object passed in.  The \f(CW\*(C`content\*(C'\fR function should return the content
805 when called.  The content can be returned in chunks.  The content
806 function will be invoked repeatedly until it return an empty string to
807 signal that there is no more content.
808 .ie n .IP "$ua\->simple_request( $request )" 4
809 .el .IP "$ua\->simple_request( \f(CW$request\fR )" 4
810 .IX Item "$ua->simple_request( $request )"
811 .PD 0
812 .ie n .IP "$ua\->simple_request( $request\fR, \f(CW$content_file )" 4
813 .el .IP "$ua\->simple_request( \f(CW$request\fR, \f(CW$content_file\fR )" 4
814 .IX Item "$ua->simple_request( $request, $content_file )"
815 .ie n .IP "$ua\->simple_request( $request\fR, \f(CW$content_cb )" 4
816 .el .IP "$ua\->simple_request( \f(CW$request\fR, \f(CW$content_cb\fR )" 4
817 .IX Item "$ua->simple_request( $request, $content_cb )"
818 .ie n .IP "$ua\->simple_request( $request\fR, \f(CW$content_cb\fR, \f(CW$read_size_hint )" 4
819 .el .IP "$ua\->simple_request( \f(CW$request\fR, \f(CW$content_cb\fR, \f(CW$read_size_hint\fR )" 4
820 .IX Item "$ua->simple_request( $request, $content_cb, $read_size_hint )"
821 .PD
822 This method dispatches a single request and returns the response
823 received.  Arguments are the same as for \fIrequest()\fR described above.
824 .Sp
825 The difference from \fIrequest()\fR is that \fIsimple_request()\fR will not try to
826 handle redirects or authentication responses.  The \fIrequest()\fR method
827 will in fact invoke this method for each simple request it sends.
828 .ie n .IP "$ua\->is_protocol_supported( $scheme )" 4
829 .el .IP "$ua\->is_protocol_supported( \f(CW$scheme\fR )" 4
830 .IX Item "$ua->is_protocol_supported( $scheme )"
831 You can use this method to test whether this user agent object supports the
832 specified \f(CW\*(C`scheme\*(C'\fR.  (The \f(CW\*(C`scheme\*(C'\fR might be a string (like 'http' or
833 \&'ftp') or it might be an \s-1URI\s0 object reference.)
834 .Sp
835 Whether a scheme is supported, is determined by the user agent's
836 \&\f(CW\*(C`protocols_allowed\*(C'\fR or \f(CW\*(C`protocols_forbidden\*(C'\fR lists (if any), and by
837 the capabilities of \s-1LWP\s0.  I.e., this will return \s-1TRUE\s0 only if \s-1LWP\s0
838 supports this protocol \fIand\fR it's permitted for this particular
839 object.
840 .Sh "Callback methods"
841 .IX Subsection "Callback methods"
842 The following methods will be invoked as requests are processed. These
843 methods are documented here because subclasses of \f(CW\*(C`LWP::UserAgent\*(C'\fR
844 might want to override their behaviour.
845 .ie n .IP "$ua\->prepare_request( $request )" 4
846 .el .IP "$ua\->prepare_request( \f(CW$request\fR )" 4
847 .IX Item "$ua->prepare_request( $request )"
848 This method is invoked by \fIsimple_request()\fR.  Its task is to modify the
849 given \f(CW$request\fR object by setting up various headers based on the
850 attributes of the user agent. The return value should normally be the
851 \&\f(CW$request\fR object passed in.  If a different request object is returned
852 it will be the one actually processed.
853 .Sp
854 The headers affected by the base implementation are; \*(L"User\-Agent\*(R",
855 \&\*(L"From\*(R", \*(L"Range\*(R" and \*(L"Cookie\*(R".
856 .ie n .IP "$ua\->redirect_ok( $prospective_request\fR, \f(CW$response )" 4
857 .el .IP "$ua\->redirect_ok( \f(CW$prospective_request\fR, \f(CW$response\fR )" 4
858 .IX Item "$ua->redirect_ok( $prospective_request, $response )"
859 This method is called by \fIrequest()\fR before it tries to follow a
860 redirection to the request in \f(CW$response\fR.  This should return a \s-1TRUE\s0
861 value if this redirection is permissible.  The \f(CW$prospective_request\fR
862 will be the request to be sent if this method returns \s-1TRUE\s0.
863 .Sp
864 The base implementation will return \s-1FALSE\s0 unless the method
865 is in the object's \f(CW\*(C`requests_redirectable\*(C'\fR list,
866 \&\s-1FALSE\s0 if the proposed redirection is to a \*(L"file://...\*(R"
867 \&\s-1URL\s0, and \s-1TRUE\s0 otherwise.
868 .ie n .IP "$ua\->get_basic_credentials( $realm\fR, \f(CW$uri\fR, \f(CW$isproxy )" 4
869 .el .IP "$ua\->get_basic_credentials( \f(CW$realm\fR, \f(CW$uri\fR, \f(CW$isproxy\fR )" 4
870 .IX Item "$ua->get_basic_credentials( $realm, $uri, $isproxy )"
871 This is called by \fIrequest()\fR to retrieve credentials for documents
872 protected by Basic or Digest Authentication.  The arguments passed in
873 is the \f(CW$realm\fR provided by the server, the \f(CW$uri\fR requested and a boolean
874 flag to indicate if this is authentication against a proxy server.
875 .Sp
876 The method should return a username and password.  It should return an
877 empty list to abort the authentication resolution attempt.  Subclasses
878 can override this method to prompt the user for the information. An
879 example of this can be found in \f(CW\*(C`lwp\-request\*(C'\fR program distributed
880 with this library.
881 .Sp
882 The base implementation simply checks a set of pre-stored member
883 variables, set up with the \fIcredentials()\fR method.
884 .ie n .IP "$ua\->progress( $status\fR, \f(CW$request_or_response )" 4
885 .el .IP "$ua\->progress( \f(CW$status\fR, \f(CW$request_or_response\fR )" 4
886 .IX Item "$ua->progress( $status, $request_or_response )"
887 This is called frequently as the response is received regardless of
888 how the content is processed.  The method is called with \f(CW$status\fR
889 \&\*(L"begin\*(R" at the start of processing the request and with \f(CW$state\fR \*(L"end\*(R"
890 before the request method returns.  In between these \f(CW$status\fR will be
891 the fraction of the response currently received or the string \*(L"tick\*(R"
892 if the fraction can't be calculated.
893 .Sp
894 When \f(CW$status\fR is \*(L"begin\*(R" the second argument is the request object,
895 otherwise it is the response object.
896 .SH "SEE ALSO"
897 .IX Header "SEE ALSO"
898 See \s-1LWP\s0 for a complete overview of libwww\-perl5.  See lwpcook
899 and the scripts \fIlwp-request\fR and \fIlwp-download\fR for examples of
900 usage.
901 .PP
902 See HTTP::Request and HTTP::Response for a description of the
903 message objects dispatched and received.  See HTTP::Request::Common
904 and HTML::Form for other ways to build request objects.
905 .PP
906 See WWW::Mechanize and WWW::Search for examples of more
907 specialized user agents based on \f(CW\*(C`LWP::UserAgent\*(C'\fR.
908 .SH "COPYRIGHT"
909 .IX Header "COPYRIGHT"
910 Copyright 1995\-2009 Gisle Aas.
911 .PP
912 This library is free software; you can redistribute it and/or
913 modify it under the same terms as Perl itself.