Net::HTTP::Spore::Response - Portable HTTP Response object for SPORE response
version 0.04
use Net:HTTP::Spore::Response; my $response = Net::HTTP::Spore::Response->new( 200, ['Content-Type', 'application/json'], '{"foo":1}'; ); $response->request($request);
Net::HTTP::Spore::Response create a HTTP response
my $res = Net::HTTP::Spore::Response->new; my $res = Net::HTTP::Spore::Response->new($status); my $res = Net::HTTP::Spore::Response->new($status, $headers); my $res = Net::HTTP::Spore::Response->new($status, $headers, $body);
Creates a new Net::HTTP::Spore::Response object.
$res->status(200); my $status = $res->status;
Gets or sets the HTTP status of the response
$res->env($env); my $env = $res->env;
Gets or sets the environment for the response. Shortcut to $res->request->env
$res->request->env
$res->body($body); my $body = $res->body;
Gets or sets the body for the response
my $raw_body = $res->raw_body
The raw_body value is the same as body when the body is sets for the first time.
$res->content_type('application/json'); my $ct = $res->content_type;
Gets or sets the content type of the response body
$res->content_length(length($body)); my $cl = $res->content_length;
$res->location('http://example.com'); my $location = $res->location;
Gets or sets the location header for the response
$res->request($request); $request = $res->request;
Gets or sets the HTTP request that created the current HTTP response.
$headers = $res->headers; $res->headers(['Content-Type' => 'application/json']);
Gets or sets HTTP response headers.
my $cl = $res->header('Content-Length'); $res->header('Content-Type' => 'application/json');
Shortcut for $res->headers->header.
$res->headers->header
my $res = Net::HTTP::Response->new($status, $headers, $body); say "http status is ".$res->[0];
Return an arrayref:
The first element of the array ref is the HTTP status
The second element is an arrayref containing the list of HTTP headers
The third and final element is the body
franck cuny <franck@lumberjaph.net>
This software is copyright (c) 2010 by linkfluence.
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 Net::HTTP::Spore, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::HTTP::Spore
CPAN shell
perl -MCPAN -e shell install Net::HTTP::Spore
For more information on module installation, please visit the detailed CPAN module installation guide.