Leser: 2
![]() |
|< 1 2 >| | ![]() |
13 Einträge, 2 Seiten |
Quoteua->get( $url , $field_name => $value, ... )
This method will dispatch a GET request on the given $url. Further arguments can be given to initialize the headers of the request. These are given as separate name/value pairs. The return value is a response object. See the HTTP::Response manpage for a description of the interface it provides.
Fields names that start with ``:'' are special. These will not initialize headers of the request but will determine how the response content is treated. The following special field names are recognized:
:content_file => $filename
:content_cb => \&callback
:read_size_hint => $bytes
If a $filename is provided with the :content_file option, then the response content will be saved here instead of in the response object. If a callback is provided with the :content_cb option then this function will be called for each chunk of the response content as it is received from the server. If neither of these options are given, then the response content will accumulate in the response object itself. This might not be suitable for very large response bodies. Only one of :content_file or :content_cb can be specified. The content of unsuccessful responses will always accumulate in the response object itself, regardless of the :content_file or :content_cb options passed in.
The :read_size_hint option is passed to the protocol module which will try to read data from the server in chunks of this size. A smaller value for the :read_size_hint will result in a higher number of callback invocations.
The callback function is called with 3 arguments: a chunk of data, a reference to the response object, and a reference to the protocol object. The callback can abort the request by invoking die(). The exception message will show up as the ``X-Died'' header field in the response returned by the get() function.
1
2
3
4
my $ua = LWP::UserAgent->new;
$ua->timeout(180);
$ua->env_proxy;
my $response = $ua->mirror("$URL", $file);
![]() |
|< 1 2 >| | ![]() |
13 Einträge, 2 Seiten |