Perl in a Nutshell

Perl in a NutshellSearch this book
Previous: 17.2 The LWP ModulesChapter 17
The LWP Library
Next: Reference: agent
 

request

 $ua->request($request, [file | $sub, size])

Performs a request for the resource specified by $request, which is an HTTP::Request object. Returns the information received from the server as an HTTP::Response object. Normally, doing a $ua->request($request) is enough. You can also specify a subroutine to process the data as it comes in, or you can provide a filename in which to store the entity body of the response. The arguments are: .S1 "Arguments"

$request

An HTTP::Request object. The object must contain the method and URL of the site to be queried. This object must exist before request is called.

file

Name of the file in which to store the response's entity body. When this option is used on request, the entity body of the returned response object will be empty.

$sub

A reference to a subroutine that will process the data of the response. If you use the optional third argument, size, the subroutine will be called any time that number of bytes is received as response data. The subroutine should expect each chunk of the entity-body data as a scalar in the first argument, an HTTP::Response object as the second argument, and an LWP::Protocol object as the third argument.

size

Optional argument specifying the number of bytes of the entity body received before the sub callback is called to process response data.


Previous: 17.2 The LWP ModulesPerl in a NutshellNext: Reference: agent
17.2 The LWP ModulesBook IndexReference: agent