AnyEvent::HTTP::Response - HTTP Response object for AnyEvent::HTTP
version 0.302
# parses argument list passed to AnyEvent::HTTP::http_request callback AnyEvent::HTTP::http_request( GET => $uri, sub { my $res = AnyEvent::HTTP::Response->new(@_); # inspect attributes print $res->header('Content-Type'); print $res->body; # upgrade to HTTP::Response my $http_res = $res->to_http_message; if( !$http_res->is_success ){ print $http_res->status_line; } } );
This object represents an HTTP response from AnyEvent::HTTP.
This is a companion class to AnyEvent::HTTP::Request.
It parses the arguments passed to the final callback in "http_request" in AnyEvent::HTTP (or produces the arguments that should be passed to that, depending on how you'd like to use it). and wraps them in an object.
It can also be converted from or to the more featureful HTTP::Response.
Accepts an argument list like the callback provided to "http_request" in AnyEvent::HTTP (see "parse_args"):
AnyEvent::HTTP::Response->new($body, \%headers);
Alternatively accepts an instance of HTTP::Response (see "from_http_message"):
AnyEvent::HTTP::Response->new( HTTP::Response->new( $code, $reason, $headers, $body ) );
Also accepts a single hashref of named attributes (see "ATTRIBUTES"):
AnyEvent::HTTP::Response->new({ body => $body, headers => \%headers, pseudo_headers => \%pseudo, });
Called by the constructor to parse the argument list passed to the callback in "http_request" in AnyEvent::HTTP and return a hashref which will be the basis for the object.
The list should look like ($body, \%headers).
($body, \%headers)
This will separate the "pseudo" headers from the regular http headers as described by "http_request" in AnyEvent::HTTP (http headers are lower-cased and pseudo headers start with an upper case letter).
Called by the constructor when "new" is passed an instance of HTTP::Response.
Response content body
Alias for "body"
HTTP Response headers
A hashref of extra fields that "http_request" in AnyEvent::HTTP returns with the http headers (the ones that start with an upper-case letter... Status, Reason, etc).
Returns a list of arguments like those passed to the callback in "http_request" in AnyEvent::HTTP.
Returns an instance of HTTP::Response to provide additional functionality.
AnyEvent::HTTP
AnyEvent::HTTP::Message (base class)
HTTP::Response More featureful object
HTTP::Message::PSGI Create an HTTP::Response from a PSGI arrayref
Randy Stauner <rwstauner@cpan.org>
This software is copyright (c) 2012 by Randy Stauner.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install AnyEvent::HTTP::Message, copy and paste the appropriate command in to your terminal.
cpanm
cpanm AnyEvent::HTTP::Message
CPAN shell
perl -MCPAN -e shell install AnyEvent::HTTP::Message
For more information on module installation, please visit the detailed CPAN module installation guide.