API / Minn\Http / Exchange

Exchange final readonly class

Minn\Http\Exchange · public/minn/src/Minn/Http/Exchange.php · 74 lines

What came back: the final response's status, headers (repeats as lists), Set-Cookie values, and body, or the transport error.

Constants and properties

propreadonly int $code

Promoted from the constructor.

propreadonly array $headers

Promoted from the constructor.

propreadonly array $cookies

Promoted from the constructor.

propreadonly string $body

Promoted from the constructor.

propreadonly ?string $error

Promoted from the constructor.

propreadonly array $head

Promoted from the constructor.

propreadonly int $errno

Promoted from the constructor.

propreadonly string $url

Promoted from the constructor.

Public

new__construct(int $code, array $headers, array $cookies, string $body, ?string $error = NULL, array $head = array ( ), int $errno = 0, string $url = '')#
$headersarray<string, string|list<string>>names lower-cased
$cookieslist<string>raw Set-Cookie header values
$headlist<string>the final response's status line and header lines as they came
$errnointcurl's error number when the transport failed; 0 when the request was refused before it was sent
$urlstringwhere the final response came from
staticfailure(string $error, int $errno, string $url): self#

An exchange in which no response arrived.

methodfailed(): bool#

Whether the transport failed before any status came back.

methodok(): bool#

A response arrived and it was a 2xx.

methodjson(): mixed#

The body decoded as JSON, or null when it is not JSON.

methodheader(string $name): ?string#

One header by any spelling of its name; a repeated header's values joined with ", ".

methodcookie(string $name): ?string#

One cookie's value from the Set-Cookie headers, percent-decoded; the last one set wins.

methodthrow(): self#

This exchange when it is ok(), otherwise a RequestFailed exception (a RuntimeException) carrying it, for callers who would rather catch than check.