Response
NAME
HTTP::Response - class encapsulating HTTP response message
SYNOPSIS
use HTTP::Response;
my $response = HTTP::Response.new(200);
say $response.is-success; # it is
DESCRIPTION
Module provides functionality to easily manage HTTP responses.
Response object is returned by the .get() method of HTTP::UserAgent.
METHODS
method new
method new(Int $code = 200, *%fields)
A constructor, takes parameters like:
code : code of the response
fields : hash of header fields (field_name => values)
my $response = HTTP::Response.new(200, :h1<v1>);
method is-success
method is-success(HTTP::Response:) returns Bool;
Returns True if response is successful (status == 2xx), False otherwise.
my $response = HTTP::Response.new(200);
say 'YAY' if $response.is-success;
method set-code
method set-code(HTTP::Response:, Int $code)
Sets code of the response.
my $response = HTTP::Response.new;
$response.set-code: 200;
method Str
method Str(HTTP::Response:) returns Str
Returns strigified object.
method parse
See HTTP::Message.
For more documentation, see HTTP::Message.