1LWP::UserAgent(3) User Contributed Perl Documentation LWP::UserAgent(3)
2
3
4
6 LWP::UserAgent - Web user agent class
7
9 require LWP::UserAgent;
10
11 my $ua = LWP::UserAgent->new;
12 $ua->timeout(10);
13 $ua->env_proxy;
14
15 my $response = $ua->get('http://search.cpan.org/');
16
17 if ($response->is_success) {
18 print $response->decoded_content; # or whatever
19 }
20 else {
21 die $response->status_line;
22 }
23
25 The "LWP::UserAgent" is a class implementing a web user agent.
26 "LWP::UserAgent" objects can be used to dispatch web requests.
27
28 In normal use the application creates an "LWP::UserAgent" object, and
29 then configures it with values for timeouts, proxies, name, etc. It
30 then creates an instance of "HTTP::Request" for the request that needs
31 to be performed. This request is then passed to one of the request
32 method the UserAgent, which dispatches it using the relevant protocol,
33 and returns a "HTTP::Response" object. There are convenience methods
34 for sending the most common request types: get(), head(), post(), put()
35 and delete(). When using these methods then the creation of the
36 request object is hidden as shown in the synopsis above.
37
38 The basic approach of the library is to use HTTP style communication
39 for all protocol schemes. This means that you will construct
40 "HTTP::Request" objects and receive "HTTP::Response" objects even for
41 non-HTTP resources like gopher and ftp. In order to achieve even more
42 similarity to HTTP style communications, gopher menus and file
43 directories are converted to HTML documents.
44
46 The following constructor methods are available:
47
48 $ua = LWP::UserAgent->new( %options )
49 This method constructs a new "LWP::UserAgent" object and returns
50 it. Key/value pair arguments may be provided to set up the initial
51 state. The following options correspond to attribute methods
52 described below:
53
54 KEY DEFAULT
55 ----------- --------------------
56 agent "libwww-perl/#.###"
57 from undef
58 conn_cache undef
59 cookie_jar undef
60 default_headers HTTP::Headers->new
61 local_address undef
62 ssl_opts { verify_hostname => 1 }
63 max_size undef
64 max_redirect 7
65 parse_head 1
66 protocols_allowed undef
67 protocols_forbidden undef
68 requests_redirectable ['GET', 'HEAD']
69 timeout 180
70
71 The following additional options are also accepted: If the
72 "env_proxy" option is passed in with a TRUE value, then proxy
73 settings are read from environment variables (see env_proxy()
74 method below). If "env_proxy" isn't provided the
75 "PERL_LWP_ENV_PROXY" environment variable controls if env_proxy()
76 is called during initialization. If the "keep_alive" option is
77 passed in, then a "LWP::ConnCache" is set up (see conn_cache()
78 method below). The "keep_alive" value is passed on as the
79 "total_capacity" for the connection cache.
80
81 $ua->clone
82 Returns a copy of the LWP::UserAgent object.
83
85 The settings of the configuration attributes modify the behaviour of
86 the "LWP::UserAgent" when it dispatches requests. Most of these can
87 also be initialized by options passed to the constructor method.
88
89 The following attribute methods are provided. The attribute value is
90 left unchanged if no argument is given. The return value from each
91 method is the old attribute value.
92
93 $ua->agent
94 $ua->agent( $product_id )
95 Get/set the product token that is used to identify the user agent
96 on the network. The agent value is sent as the "User-Agent" header
97 in the requests. The default is the string returned by the
98 _agent() method (see below).
99
100 If the $product_id ends with space then the _agent() string is
101 appended to it.
102
103 The user agent string should be one or more simple product
104 identifiers with an optional version number separated by the "/"
105 character. Examples are:
106
107 $ua->agent('Checkbot/0.4 ' . $ua->_agent);
108 $ua->agent('Checkbot/0.4 '); # same as above
109 $ua->agent('Mozilla/5.0');
110 $ua->agent(""); # don't identify
111
112 $ua->_agent
113 Returns the default agent identifier. This is a string of the form
114 "libwww-perl/#.###", where "#.###" is substituted with the version
115 number of this library.
116
117 $ua->from
118 $ua->from( $email_address )
119 Get/set the e-mail address for the human user who controls the
120 requesting user agent. The address should be machine-usable, as
121 defined in RFC 822. The "from" value is send as the "From" header
122 in the requests. Example:
123
124 $ua->from('gaas@cpan.org');
125
126 The default is to not send a "From" header. See the
127 default_headers() method for the more general interface that allow
128 any header to be defaulted.
129
130 $ua->cookie_jar
131 $ua->cookie_jar( $cookie_jar_obj )
132 Get/set the cookie jar object to use. The only requirement is that
133 the cookie jar object must implement the extract_cookies($request)
134 and add_cookie_header($response) methods. These methods will then
135 be invoked by the user agent as requests are sent and responses are
136 received. Normally this will be a "HTTP::Cookies" object or some
137 subclass.
138
139 The default is to have no cookie_jar, i.e. never automatically add
140 "Cookie" headers to the requests.
141
142 Shortcut: If a reference to a plain hash is passed in as the
143 $cookie_jar_object, then it is replaced with an instance of
144 "HTTP::Cookies" that is initialized based on the hash. This form
145 also automatically loads the "HTTP::Cookies" module. It means
146 that:
147
148 $ua->cookie_jar({ file => "$ENV{HOME}/.cookies.txt" });
149
150 is really just a shortcut for:
151
152 require HTTP::Cookies;
153 $ua->cookie_jar(HTTP::Cookies->new(file => "$ENV{HOME}/.cookies.txt"));
154
155 $ua->default_headers
156 $ua->default_headers( $headers_obj )
157 Get/set the headers object that will provide default header values
158 for any requests sent. By default this will be an empty
159 "HTTP::Headers" object.
160
161 $ua->default_header( $field )
162 $ua->default_header( $field => $value )
163 This is just a short-cut for $ua->default_headers->header( $field
164 => $value ). Example:
165
166 $ua->default_header('Accept-Encoding' => scalar HTTP::Message::decodable());
167 $ua->default_header('Accept-Language' => "no, en");
168
169 $ua->conn_cache
170 $ua->conn_cache( $cache_obj )
171 Get/set the "LWP::ConnCache" object to use. See LWP::ConnCache for
172 details.
173
174 $ua->credentials( $netloc, $realm )
175 $ua->credentials( $netloc, $realm, $uname, $pass )
176 Get/set the user name and password to be used for a realm.
177
178 The $netloc is a string of the form "<host>:<port>". The username
179 and password will only be passed to this server. Example:
180
181 $ua->credentials("www.example.com:80", "Some Realm", "foo", "secret");
182
183 $ua->local_address
184 $ua->local_address( $address )
185 Get/set the local interface to bind to for network connections.
186 The interface can be specified as a hostname or an IP address.
187 This value is passed as the "LocalAddr" argument to
188 IO::Socket::INET.
189
190 $ua->max_size
191 $ua->max_size( $bytes )
192 Get/set the size limit for response content. The default is
193 "undef", which means that there is no limit. If the returned
194 response content is only partial, because the size limit was
195 exceeded, then a "Client-Aborted" header will be added to the
196 response. The content might end up longer than "max_size" as we
197 abort once appending a chunk of data makes the length exceed the
198 limit. The "Content-Length" header, if present, will indicate the
199 length of the full content and will normally not be the same as
200 "length($res->content)".
201
202 $ua->max_redirect
203 $ua->max_redirect( $n )
204 This reads or sets the object's limit of how many times it will
205 obey redirection responses in a given request cycle.
206
207 By default, the value is 7. This means that if you call request()
208 method and the response is a redirect elsewhere which is in turn a
209 redirect, and so on seven times, then LWP gives up after that
210 seventh request.
211
212 $ua->parse_head
213 $ua->parse_head( $boolean )
214 Get/set a value indicating whether we should initialize response
215 headers from the <head> section of HTML documents. The default is
216 TRUE. Do not turn this off, unless you know what you are doing.
217
218 $ua->protocols_allowed
219 $ua->protocols_allowed( \@protocols )
220 This reads (or sets) this user agent's list of protocols that the
221 request methods will exclusively allow. The protocol names are
222 case insensitive.
223
224 For example: "$ua->protocols_allowed( [ 'http', 'https'] );" means
225 that this user agent will allow only those protocols, and attempts
226 to use this user agent to access URLs with any other schemes (like
227 "ftp://...") will result in a 500 error.
228
229 To delete the list, call: "$ua->protocols_allowed(undef)"
230
231 By default, an object has neither a "protocols_allowed" list, nor a
232 "protocols_forbidden" list.
233
234 Note that having a "protocols_allowed" list causes any
235 "protocols_forbidden" list to be ignored.
236
237 $ua->protocols_forbidden
238 $ua->protocols_forbidden( \@protocols )
239 This reads (or sets) this user agent's list of protocols that the
240 request method will not allow. The protocol names are case
241 insensitive.
242
243 For example: "$ua->protocols_forbidden( [ 'file', 'mailto'] );"
244 means that this user agent will not allow those protocols, and
245 attempts to use this user agent to access URLs with those schemes
246 will result in a 500 error.
247
248 To delete the list, call: "$ua->protocols_forbidden(undef)"
249
250 $ua->requests_redirectable
251 $ua->requests_redirectable( \@requests )
252 This reads or sets the object's list of request names that
253 "$ua->redirect_ok(...)" will allow redirection for. By default,
254 this is "['GET', 'HEAD']", as per RFC 2616. To change to include
255 'POST', consider:
256
257 push @{ $ua->requests_redirectable }, 'POST';
258
259 $ua->show_progress
260 $ua->show_progress( $boolean )
261 Get/set a value indicating whether a progress bar should be
262 displayed on on the terminal as requests are processed. The default
263 is FALSE.
264
265 $ua->timeout
266 $ua->timeout( $secs )
267 Get/set the timeout value in seconds. The default timeout() value
268 is 180 seconds, i.e. 3 minutes.
269
270 The requests is aborted if no activity on the connection to the
271 server is observed for "timeout" seconds. This means that the time
272 it takes for the complete transaction and the request() method to
273 actually return might be longer.
274
275 $ua->ssl_opts
276 $ua->ssl_opts( $key )
277 $ua->ssl_opts( $key => $value )
278 Get/set the options for SSL connections. Without argument return
279 the list of options keys currently set. With a single argument
280 return the current value for the given option. With 2 arguments
281 set the option value and return the old. Setting an option to the
282 value "undef" removes this option.
283
284 The options that LWP relates to are:
285
286 "verify_hostname" => $bool
287 When TRUE LWP will for secure protocol schemes ensure it
288 connects to servers that have a valid certificate matching the
289 expected hostname. If FALSE no checks are made and you can't
290 be sure that you communicate with the expected peer. The no
291 checks behaviour was the default for libwww-perl-5.837 and
292 earlier releases.
293
294 This option is initialized from the
295 PERL_LWP_SSL_VERIFY_HOSTNAME environment variable. If this
296 environment variable isn't set; then "verify_hostname" defaults
297 to 1.
298
299 "SSL_ca_file" => $path
300 The path to a file containing Certificate Authority
301 certificates. A default setting for this option is provided by
302 checking the environment variables "PERL_LWP_SSL_CA_FILE" and
303 "HTTPS_CA_FILE" in order.
304
305 "SSL_ca_path" => $path
306 The path to a directory containing files containing Certificate
307 Authority certificates. A default setting for this option is
308 provided by checking the environment variables
309 "PERL_LWP_SSL_CA_PATH" and "HTTPS_CA_DIR" in order.
310
311 Other options can be set and are processed directly by the SSL
312 Socket implementation in use. See IO::Socket::SSL or Net::SSL for
313 details.
314
315 The libwww-perl core no longer bundles protocol plugins for SSL.
316 You will need to install LWP::Protocol::https separately to enable
317 support for processing https-URLs.
318
319 Proxy attributes
320 The following methods set up when requests should be passed via a proxy
321 server.
322
323 $ua->proxy(\@schemes, $proxy_url)
324 $ua->proxy($scheme, $proxy_url)
325 Set/retrieve proxy URL for a scheme:
326
327 $ua->proxy(['http', 'ftp'], 'http://proxy.sn.no:8001/');
328 $ua->proxy('gopher', 'http://proxy.sn.no:8001/');
329
330 The first form specifies that the URL is to be used for proxying of
331 access methods listed in the list in the first method argument,
332 i.e. 'http' and 'ftp'.
333
334 The second form shows a shorthand form for specifying proxy URL for
335 a single access scheme.
336
337 $ua->no_proxy( $domain, ... )
338 Do not proxy requests to the given domains. Calling no_proxy
339 without any domains clears the list of domains. Eg:
340
341 $ua->no_proxy('localhost', 'example.com');
342
343 $ua->env_proxy
344 Load proxy settings from *_proxy environment variables. You might
345 specify proxies like this (sh-syntax):
346
347 gopher_proxy=http://proxy.my.place/
348 wais_proxy=http://proxy.my.place/
349 no_proxy="localhost,example.com"
350 export gopher_proxy wais_proxy no_proxy
351
352 csh or tcsh users should use the "setenv" command to define these
353 environment variables.
354
355 On systems with case insensitive environment variables there exists
356 a name clash between the CGI environment variables and the
357 "HTTP_PROXY" environment variable normally picked up by
358 env_proxy(). Because of this "HTTP_PROXY" is not honored for CGI
359 scripts. The "CGI_HTTP_PROXY" environment variable can be used
360 instead.
361
362 Handlers
363 Handlers are code that injected at various phases during the processing
364 of requests. The following methods are provided to manage the active
365 handlers:
366
367 $ua->add_handler( $phase => \&cb, %matchspec )
368 Add handler to be invoked in the given processing phase. For how
369 to specify %matchspec see "Matching" in HTTP::Config.
370
371 The possible values $phase and the corresponding callback
372 signatures are:
373
374 request_preprepare => sub { my($request, $ua, $h) = @_; ... }
375 The handler is called before the "request_prepare" and other
376 standard initialization of of the request. This can be used to
377 set up headers and attributes that the "request_prepare"
378 handler depends on. Proxy initialization should take place
379 here; but in general don't register handlers for this phase.
380
381 request_prepare => sub { my($request, $ua, $h) = @_; ... }
382 The handler is called before the request is sent and can modify
383 the request any way it see fit. This can for instance be used
384 to add certain headers to specific requests.
385
386 The method can assign a new request object to $_[0] to replace
387 the request that is sent fully.
388
389 The return value from the callback is ignored. If an exception
390 is raised it will abort the request and make the request method
391 return a "400 Bad request" response.
392
393 request_send => sub { my($request, $ua, $h) = @_; ... }
394 This handler gets a chance of handling requests before they're
395 sent to the protocol handlers. It should return an
396 HTTP::Response object if it wishes to terminate the processing;
397 otherwise it should return nothing.
398
399 The "response_header" and "response_data" handlers will not be
400 invoked for this response, but the "response_done" will be.
401
402 response_header => sub { my($response, $ua, $h) = @_; ... }
403 This handler is called right after the response headers have
404 been received, but before any content data. The handler might
405 set up handlers for data and might croak to abort the request.
406
407 The handler might set the $response->{default_add_content}
408 value to control if any received data should be added to the
409 response object directly. This will initially be false if the
410 $ua->request() method was called with a $content_file or
411 $content_cb argument; otherwise true.
412
413 response_data => sub { my($response, $ua, $h, $data) = @_; ... }
414 This handler is called for each chunk of data received for the
415 response. The handler might croak to abort the request.
416
417 This handler needs to return a TRUE value to be called again
418 for subsequent chunks for the same request.
419
420 response_done => sub { my($response, $ua, $h) = @_; ... }
421 The handler is called after the response has been fully
422 received, but before any redirect handling is attempted. The
423 handler can be used to extract information or modify the
424 response.
425
426 response_redirect => sub { my($response, $ua, $h) = @_; ... }
427 The handler is called in $ua->request after "response_done".
428 If the handler returns an HTTP::Request object we'll start over
429 with processing this request instead.
430
431 $ua->remove_handler( undef, %matchspec )
432 $ua->remove_handler( $phase, %matchspec )
433 Remove handlers that match the given %matchspec. If $phase is not
434 provided remove handlers from all phases.
435
436 Be careful as calling this function with %matchspec that is not not
437 specific enough can remove handlers not owned by you. It's
438 probably better to use the set_my_handler() method instead.
439
440 The removed handlers are returned.
441
442 $ua->set_my_handler( $phase, $cb, %matchspec )
443 Set handlers private to the executing subroutine. Works by
444 defaulting an "owner" field to the %matchspec that holds the name
445 of the called subroutine. You might pass an explicit "owner" to
446 override this.
447
448 If $cb is passed as "undef", remove the handler.
449
450 $ua->get_my_handler( $phase, %matchspec )
451 $ua->get_my_handler( $phase, %matchspec, $init )
452 Will retrieve the matching handler as hash ref.
453
454 If $init is passed passed as a TRUE value, create and add the
455 handler if it's not found. If $init is a subroutine reference,
456 then it's called with the created handler hash as argument. This
457 sub might populate the hash with extra fields; especially the
458 callback. If $init is a hash reference, merge the hashes.
459
460 $ua->handlers( $phase, $request )
461 $ua->handlers( $phase, $response )
462 Returns the handlers that apply to the given request or response at
463 the given processing phase.
464
466 The methods described in this section are used to dispatch requests via
467 the user agent. The following request methods are provided:
468
469 $ua->get( $url )
470 $ua->get( $url , $field_name => $value, ... )
471 This method will dispatch a "GET" request on the given $url.
472 Further arguments can be given to initialize the headers of the
473 request. These are given as separate name/value pairs. The return
474 value is a response object. See HTTP::Response for a description
475 of the interface it provides.
476
477 There will still be a response object returned when LWP can't
478 connect to the server specified in the URL or when other failures
479 in protocol handlers occur. These internal responses use the
480 standard HTTP status codes, so the responses can't be
481 differentiated by testing the response status code alone. Error
482 responses that LWP generates internally will have the "Client-
483 Warning" header set to the value "Internal response". If you need
484 to differentiate these internal responses from responses that a
485 remote server actually generates, you need to test this header
486 value.
487
488 Fields names that start with ":" are special. These will not
489 initialize headers of the request but will determine how the
490 response content is treated. The following special field names are
491 recognized:
492
493 :content_file => $filename
494 :content_cb => \&callback
495 :read_size_hint => $bytes
496
497 If a $filename is provided with the ":content_file" option, then
498 the response content will be saved here instead of in the response
499 object. If a callback is provided with the ":content_cb" option
500 then this function will be called for each chunk of the response
501 content as it is received from the server. If neither of these
502 options are given, then the response content will accumulate in the
503 response object itself. This might not be suitable for very large
504 response bodies. Only one of ":content_file" or ":content_cb" can
505 be specified. The content of unsuccessful responses will always
506 accumulate in the response object itself, regardless of the
507 ":content_file" or ":content_cb" options passed in.
508
509 The ":read_size_hint" option is passed to the protocol module which
510 will try to read data from the server in chunks of this size. A
511 smaller value for the ":read_size_hint" will result in a higher
512 number of callback invocations.
513
514 The callback function is called with 3 arguments: a chunk of data,
515 a reference to the response object, and a reference to the protocol
516 object. The callback can abort the request by invoking die(). The
517 exception message will show up as the "X-Died" header field in the
518 response returned by the get() function.
519
520 $ua->head( $url )
521 $ua->head( $url , $field_name => $value, ... )
522 This method will dispatch a "HEAD" request on the given $url.
523 Otherwise it works like the get() method described above.
524
525 $ua->post( $url, \%form )
526 $ua->post( $url, \@form )
527 $ua->post( $url, \%form, $field_name => $value, ... )
528 $ua->post( $url, $field_name => $value,... Content => \%form )
529 $ua->post( $url, $field_name => $value,... Content => \@form )
530 $ua->post( $url, $field_name => $value,... Content => $content )
531 This method will dispatch a "POST" request on the given $url, with
532 %form or @form providing the key/value pairs for the fill-in form
533 content. Additional headers and content options are the same as for
534 the get() method.
535
536 This method will use the POST() function from
537 "HTTP::Request::Common" to build the request. See
538 HTTP::Request::Common for a details on how to pass form content and
539 other advanced features.
540
541 $ua->put( $url, \%form )
542 $ua->put( $url, \@form )
543 $ua->put( $url, \%form, $field_name => $value, ... )
544 $ua->put( $url, $field_name => $value,... Content => \%form )
545 $ua->put( $url, $field_name => $value,... Content => \@form )
546 $ua->put( $url, $field_name => $value,... Content => $content )
547 This method will dispatch a "PUT" request on the given $url, with
548 %form or @form providing the key/value pairs for the fill-in form
549 content. Additional headers and content options are the same as for
550 the get() method.
551
552 This method will use the PUT() function from
553 "HTTP::Request::Common" to build the request. See
554 HTTP::Request::Common for a details on how to pass form content and
555 other advanced features.
556
557 $ua->delete( $url )
558 $ua->delete( $url, $field_name => $value, ... )
559 This method will dispatch a "DELETE" request on the given $url.
560 Additional headers and content options are the same as for the
561 get() method.
562
563 This method will use the DELETE() function from
564 "HTTP::Request::Common" to build the request. See
565 HTTP::Request::Common for a details on how to pass form content and
566 other advanced features.
567
568 $ua->mirror( $url, $filename )
569 This method will get the document identified by $url and store it
570 in file called $filename. If the file already exists, then the
571 request will contain an "If-Modified-Since" header matching the
572 modification time of the file. If the document on the server has
573 not changed since this time, then nothing happens. If the document
574 has been updated, it will be downloaded again. The modification
575 time of the file will be forced to match that of the server.
576
577 The return value is the the response object.
578
579 $ua->request( $request )
580 $ua->request( $request, $content_file )
581 $ua->request( $request, $content_cb )
582 $ua->request( $request, $content_cb, $read_size_hint )
583 This method will dispatch the given $request object. Normally this
584 will be an instance of the "HTTP::Request" class, but any object
585 with a similar interface will do. The return value is a response
586 object. See HTTP::Request and HTTP::Response for a description of
587 the interface provided by these classes.
588
589 The request() method will process redirects and authentication
590 responses transparently. This means that it may actually send
591 several simple requests via the simple_request() method described
592 below.
593
594 The request methods described above; get(), head(), post() and
595 mirror(), will all dispatch the request they build via this method.
596 They are convenience methods that simply hides the creation of the
597 request object for you.
598
599 The $content_file, $content_cb and $read_size_hint all correspond
600 to options described with the get() method above.
601
602 You are allowed to use a CODE reference as "content" in the request
603 object passed in. The "content" function should return the content
604 when called. The content can be returned in chunks. The content
605 function will be invoked repeatedly until it return an empty string
606 to signal that there is no more content.
607
608 $ua->simple_request( $request )
609 $ua->simple_request( $request, $content_file )
610 $ua->simple_request( $request, $content_cb )
611 $ua->simple_request( $request, $content_cb, $read_size_hint )
612 This method dispatches a single request and returns the response
613 received. Arguments are the same as for request() described above.
614
615 The difference from request() is that simple_request() will not try
616 to handle redirects or authentication responses. The request()
617 method will in fact invoke this method for each simple request it
618 sends.
619
620 $ua->is_online
621 Tries to determine if you have access to the Internet. Returns
622 TRUE if the built-in heuristics determine that the user agent is
623 able to access the Internet (over HTTP). See also LWP::Online.
624
625 $ua->is_protocol_supported( $scheme )
626 You can use this method to test whether this user agent object
627 supports the specified "scheme". (The "scheme" might be a string
628 (like 'http' or 'ftp') or it might be an URI object reference.)
629
630 Whether a scheme is supported, is determined by the user agent's
631 "protocols_allowed" or "protocols_forbidden" lists (if any), and by
632 the capabilities of LWP. I.e., this will return TRUE only if LWP
633 supports this protocol and it's permitted for this particular
634 object.
635
636 Callback methods
637 The following methods will be invoked as requests are processed. These
638 methods are documented here because subclasses of "LWP::UserAgent"
639 might want to override their behaviour.
640
641 $ua->prepare_request( $request )
642 This method is invoked by simple_request(). Its task is to modify
643 the given $request object by setting up various headers based on
644 the attributes of the user agent. The return value should normally
645 be the $request object passed in. If a different request object is
646 returned it will be the one actually processed.
647
648 The headers affected by the base implementation are; "User-Agent",
649 "From", "Range" and "Cookie".
650
651 $ua->redirect_ok( $prospective_request, $response )
652 This method is called by request() before it tries to follow a
653 redirection to the request in $response. This should return a TRUE
654 value if this redirection is permissible. The $prospective_request
655 will be the request to be sent if this method returns TRUE.
656
657 The base implementation will return FALSE unless the method is in
658 the object's "requests_redirectable" list, FALSE if the proposed
659 redirection is to a "file://..." URL, and TRUE otherwise.
660
661 $ua->get_basic_credentials( $realm, $uri, $isproxy )
662 This is called by request() to retrieve credentials for documents
663 protected by Basic or Digest Authentication. The arguments passed
664 in is the $realm provided by the server, the $uri requested and a
665 boolean flag to indicate if this is authentication against a proxy
666 server.
667
668 The method should return a username and password. It should return
669 an empty list to abort the authentication resolution attempt.
670 Subclasses can override this method to prompt the user for the
671 information. An example of this can be found in "lwp-request"
672 program distributed with this library.
673
674 The base implementation simply checks a set of pre-stored member
675 variables, set up with the credentials() method.
676
677 $ua->progress( $status, $request_or_response )
678 This is called frequently as the response is received regardless of
679 how the content is processed. The method is called with $status
680 "begin" at the start of processing the request and with $state
681 "end" before the request method returns. In between these $status
682 will be the fraction of the response currently received or the
683 string "tick" if the fraction can't be calculated.
684
685 When $status is "begin" the second argument is the request object,
686 otherwise it is the response object.
687
689 See LWP for a complete overview of libwww-perl5. See lwpcook and the
690 scripts lwp-request and lwp-download for examples of usage.
691
692 See HTTP::Request and HTTP::Response for a description of the message
693 objects dispatched and received. See HTTP::Request::Common and
694 HTML::Form for other ways to build request objects.
695
696 See WWW::Mechanize and WWW::Search for examples of more specialized
697 user agents based on "LWP::UserAgent".
698
700 Copyright 1995-2009 Gisle Aas.
701
702 This library is free software; you can redistribute it and/or modify it
703 under the same terms as Perl itself.
704
705
706
707perl v5.16.3 2013-03-11 LWP::UserAgent(3)