NAME

Fetch::Response - an HTTP response from Fetch

SYNOPSIS

my $res = $ua->get($url)->get;
if ($res->is_success) {
    print $res->status, "\n";
    print $res->header('Content-Type'), "\n";
    print $res->content;
}

METHODS

status

The numeric HTTP status code.

headers

The response headers as a Fetch::Headers object, in the order received. It is itself a blessed [ key, value, key, value, ... ] arrayref, so older code that dereferenced @{$res->headers} still works, while get/get_all give case-insensitive and multi-valued access (get_all('set-cookie')).

header($name)

The value of a single header, matched case-insensitively (first occurrence).

content

The response body as bytes.

json

my $data = $res->json;

Decode the response body as JSON into a Perl data structure. true/false become JSON::PP::Boolean values and null becomes undef. Dies if the body is not valid JSON. Uses Cpanel::JSON::XS when installed, falling back to core JSON::PP.

is_success / is_redirect

True for 2xx / 3xx status codes respectively.

AUTHOR

LNATION <email@lnation.org>

LICENSE AND COPYRIGHT

This software is Copyright (c) 2026 by LNATION. This is free software, licensed under the Artistic License 2.0.