Name

request

Synopsis

$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 provide a filename in which to store the entity body of the response. The arguments are:

$ 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.

Get Perl in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.