UniEvent::HTTP::Response - HTTP client response class
http_request({ uri => "http://example.com", response_callback => sub { my ($request, $response, $error) = @_; say $response->code; say $response->message; say $response->body; say Dumper($response->headers); say Dumper($response->cookies); ... }, }); my $response = http_request_sync($request); say $response->body; ...
Objects of UniEvent::HTTP::Response represent http response on client side and are passed to request callbacks. Normally, response objects are not created by user, instead a response object is created automatically when parsing response. You can customize how response object is created via response_factory(), see UniEvent::HTTP::Request.
UniEvent::HTTP::Response
response_factory()
UniEvent::HTTP::Response inherits from Protocol::HTTP::Response. So for complete documenation you need to also read Protocol::HTTP::Response's docs.
See detailed description in corresponding method docs.
All methods of Protocol::HTTP::Response also apply.
Constructs a response object.
NOTE: If you create your own response class inherited from UniEvent::HTTP::Response, you must proxy to original new() method and use its result as the object you return. By default it is a reference to undef, you can upgrade it to hash-based object via XS::Framework::obj2hv:
new()
XS::Framework::obj2hv
package MyResponse; use parent 'UniEvent::HTTP::Response'; sub new { my $self = shift->SUPER::new(); XS::Framework::obj2hv($self); $self->{prop} = "val"; return $self; } ... $request->response_factory(sub { MyResponse->new });
Returns true if response has been fully received including the whole body. This method can return false in partial_callback (see UniEvent::HTTP::Request) or if an error occurs.
partial_callback
To install UniEvent::HTTP, copy and paste the appropriate command in to your terminal.
cpanm
cpanm UniEvent::HTTP
CPAN shell
perl -MCPAN -e shell install UniEvent::HTTP
For more information on module installation, please visit the detailed CPAN module installation guide.