NAME
Protocol::Tus::Response
SYNOPSIS
use Protocol::Tus::Response;
my $tus = ...; # assume it's a Protocol::Tus object
my $response = $tus->HTTP_request(...);
my $status = $response->status;
my $headers_href = $response->headers;
my $body_if_any = $response->body;
my $exception_if_any = $response->exception;
my $upload_id = $response->id;
DESCRIPTION
Wrap response to a Protocol::Tus request with convenience accessors and methods.
INTERFACE
as_hash
my $hash_ref = $response->as_hash;
Return a hash reference with status, headers, and body.
body
my $body = $response->body;
Accessor to the body of the response, if any. Defaults to the empty string.
exception
my $exception = $response->exception;
Accessor to an exception object (most probably Ouch) if any occurred. useful to generate logs.
headers
my $headers_href = $response->headers;
Accessor to a hash reference with headers. The method is read-only but the headers can be manipulated.
id
my $id = $response->id;
Accessor to the upload identifier, returns undef if "upload" is not defined.
is_error
my $bool = $response->is_error;
Check if the response's "status" represents an error (any status code greater than or equal to 400).
more_headers
$response->more_headers({ Foo => 'Bar', Baz => 10 });
Add headers to the ones already present. It does NOTHING fancy, so headers with the same name are substituted and headers that have different keys that case-fold to the same string are saved differently.
It's not a method intended for general consumption but still.
new_from_exception
my $response = Protocol::Tus::Response->new_from_exception($e);
Generate a new response from an exception. If the input $e is a Ouch object, it will use its methods to set the "status" and "body" parts; otherwise the status will be 500 and the body a generic one. In all cases, the input exception $e is saved as "exception".
status
my $status = $response->status;
Accessor to the status code of the response.
upload
my $upload = $response->upload;
Accessor to the upload sub-object, if any.
ANYTHING ELSE (INCLUDING AUTHOR, COPYRIGHT AND LICENSE)
See documentation for Protocol::Tus.