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
| prop | readonly int $code | Promoted from the constructor. |
| prop | readonly array $headers | Promoted from the constructor. |
| prop | readonly array $cookies | Promoted from the constructor. |
| prop | readonly string $body | Promoted from the constructor. |
| prop | readonly ?string $error | Promoted from the constructor. |
| prop | readonly array $head | Promoted from the constructor. |
| prop | readonly int $errno | Promoted from the constructor. |
| prop | readonly 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 = '')# |
| |||||||||||||||
| static | failure(string $error, int $errno, string $url): self# | An exchange in which no response arrived. | |||||||||||||||
| method | failed(): bool# | Whether the transport failed before any status came back. | |||||||||||||||
| method | ok(): bool# | A response arrived and it was a 2xx. | |||||||||||||||
| method | json(): mixed# | The body decoded as JSON, or null when it is not JSON. | |||||||||||||||
| method | header(string $name): ?string# | One header by any spelling of its name; a repeated header's values joined with ", ". | |||||||||||||||
| method | cookie(string $name): ?string# | One cookie's value from the Set-Cookie headers, percent-decoded; the last one set wins. | |||||||||||||||
| method | throw(): self# | This exchange when it is ok(), otherwise a RequestFailed exception (a RuntimeException) carrying it, for callers who would rather catch than check. |
Nothing matches.