ClientResponse class final

A response to an outgoing request (Laravel's Http\Client\Response).

Constructors

ClientResponse(int status, String body, {Headers? headers})
A response with status and body; tests build them for fakes.
ClientResponse.fake(Object? body, {int status = 200, Map<String, String> headers = const {}})
A stubbed response: maps and lists become JSON.
factory

Properties

body → String
The body as text.
final
clientError → bool
Whether the status is 4xx.
no setter
failed → bool
Whether the status is 4xx or 5xx.
no setter
hashCode → int
The hash code for this object.
no setterinherited
headers → Headers
The response headers.
final
ok → bool
Whether the status is 200.
no setter
redirect → bool
Whether the status is 3xx.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
serverError → bool
Whether the status is 5xx.
no setter
status → int
The status code.
final
successful → bool
Whether the status is 2xx.
no setter

Methods

The first value of the header name, or null.
json([String? key, Object? fallback]) → Object?
The decoded JSON body, or a value in it by dot path.
jsonMap() → Map<String, Object?>
The decoded JSON object (empty when the body is not one).
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
throwIfClientError() → ClientResponse
Throws RequestException on a 4xx; returns this response otherwise.
throwIfFailed() → ClientResponse
Throws RequestException on a 4xx or 5xx response.
throwIfServerError() → ClientResponse
Throws RequestException on a 5xx; returns this response otherwise.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited