NAME

Uniform::HTTP::Response - Framework-neutral HTTP response

SYNOPSIS

use Uniform::HTTP::Response;

my $response = Uniform::HTTP::Response->new(
    status  => 200,
    headers => [
        [ 'Content-Type', 'text/plain' ],
    ],
    body => "hello\n",
);

DESCRIPTION

Uniform::HTTP::Response represents HTTP response data without sending a response or owning a connection, transaction, framework, or event loop.

A response always has a status. It may also carry a reason phrase, version, headers, and a buffered body.

CONSTRUCTOR

new

my $response = Uniform::HTTP::Response->new(
    status => 200,
    body   => 'ok',
);

status is required.

Optional arguments are:

  • reason

  • version

  • headers

  • body

METHODS

status

my $status = $response->status;

Returns the HTTP status code.

Set it with:

$response->status(404);

Valid status values are integers from 100 through 599.

reason

my $reason = $response->reason;

Returns the reason phrase, or undef when none was supplied.

Set or clear it with:

$response->reason('Not Found');
$response->reason(undef);

Uniform does not invent standard reason phrases such as OK.

INHERITED METHODS

Headers, bodies, versions, mutability, and completeness come from Uniform::HTTP::Message.

SEE ALSO

Uniform::HTTP, Uniform::HTTP::Message, Uniform::HTTP::Request.

AUTHOR

Joshua S. Day <HAX@cpan.org>

LICENSE

This software is available under the MIT License.