Handle class abstract mixin Clients

A client that allows retrying HTTP request with different request on response or errors

Note: This adds a header 'used-handle' by default in request which is used by JsonModelSerializer to disable asynchronous deserialization which would otherwise fail with an error if handle is used to update request.

Implemented types
Implementers

Constructors

Handle.client(Client client, {WhenCallback? when, WhenErrorCallback? whenError, WhenRetriedCallback? onRetry, DelayCallback? delay, WhenRequestCallback? updateRequest})
Creates a client that allows retrying HTTP request with different request on response or errors
factory

Properties

hashCode int
The hash code for this object.
no setterinherited
inner → Client
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

calculateDelay(int retryCount) Duration?
Returns a duration of delay before retrying a request
override
close() → void
Closes the client and cleans up any resources associated with it.
inherited
delete(Uri url, {Map<String, String>? headers, Object? body, Encoding? encoding}) Future<Response>
Sends an HTTP DELETE request with the given headers to the given URL.
inherited
get(Uri url, {Map<String, String>? headers}) Future<Response>
Sends an HTTP GET request with the given headers to the given URL.
inherited
getUpdatedRequest(BaseRequest originalRequest, BaseRequest lastRequest, FinalizedBodyStreamCallback bodyStream, BaseResponse? response, int retryCount) FutureOr<BaseRequest>
Returns an updated request that should be retried
override
Sends an HTTP HEAD request with the given headers to the given URL.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onRequestRetry(BaseRequest request, BaseResponse? response, int retryCount) FutureOr<void>
This is called when a request is being retried. This is called after the request is updated and before the request is sent.
override
patch(Uri url, {Map<String, String>? headers, Object? body, Encoding? encoding}) Future<Response>
Sends an HTTP PATCH request with the given headers and body to the given URL.
inherited
post(Uri url, {Map<String, String>? headers, Object? body, Encoding? encoding}) Future<Response>
Sends an HTTP POST request with the given headers and body to the given URL.
inherited
put(Uri url, {Map<String, String>? headers, Object? body, Encoding? encoding}) Future<Response>
Sends an HTTP PUT request with the given headers and body to the given URL.
inherited
read(Uri url, {Map<String, String>? headers}) Future<String>
Sends an HTTP GET request with the given headers to the given URL and returns a Future that completes to the body of the response as a String.
inherited
readBytes(Uri url, {Map<String, String>? headers}) Future<Uint8List>
Sends an HTTP GET request with the given headers to the given URL and returns a Future that completes to the body of the response as a list of bytes.
inherited
retryRequestWhen(BaseResponse response, int retryCount) FutureOr<bool>
This is used to determine whether a request should be retried
override
retryRequestWhenError(Object object, StackTrace stackTrace, int retryCount) FutureOr<bool>
This is used to determine whether a request should be retried when an error is thrown
override
send(BaseRequest originalRequest) Future<StreamedResponse>
Sends an HTTP request and asynchronously returns the response.
toString() String
A string representation of this object.
inherited

Operators

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