The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

HTTP::Response - Class encapsulating HTTP Responses

SYNOPSIS

 require HTTP::Response;

DESCRIPTION

HTTP::Response is a class encapsulating HTTP style responses, consisting of a response line, a MIME header, and usually content. Note that the LWP library also uses this HTTP style responses for non-HTTP protocols.

Instances of this class are usually created by the request() method of an LWP::UserAgent object:

 ...
 $response = $ua->request($request)
 if ($response->isSuccess) {
     print $response->content;
 } else {
     print $response->errorAsHTML;    
 }

METHODS

HTTP::Response is a subclass of HTTP::Message and therefore inherits its methods. The inherited methods are header, pushHeader, removeHeader headerAsString and content. See HTTP::Message for details.

new($rc [, $msg])

Constructs a new HTTP::Response object describing a response with response code $rc and optional message $msg

code([$code])

message([$message])

request([$request])

previous([$previousResponse])

These methods provide public access to the member variables. The first two containing respectively the response code and the message of the response.

The request attribute is used to record the request that gave this response. You should for instance access the base URL of an document like this: $response-request->url;>.

The previous attribute is used to link together chains of responses. You get chains of responses if the first response is redirect or unauthorized.

asString()

Method returning a textual representation of the request. Mainly useful for debugging purposes. It takes no arguments.

isSuccess

isRedirect

isError

These methods indicate if the response was sucessful, a redirection, or an error.

errorAsHTML()

Return string with a complete HTML document indicating what error occurred