RhttpClient class
An HTTP client that is used to make requests. Creating this is an expensive operation, so it is recommended to reuse it. Internally, it holds a connection pool and other resources on the Rust side.
Constructors
-
RhttpClient.createSync({ClientSettings? settings, List<
Interceptor> ? interceptors}) -
Creates a new HTTP client synchronously.
Use this method if your app is starting up to simplify the code
that might arise by using async/await.
factory
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- interceptor → Interceptor?
-
One or more interceptors that are used to modify requests and responses.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- settings → ClientSettings
-
Settings for the client.
final
Methods
-
delete(
String url, {Map< String, String> ? query, HttpHeaders? headers, HttpBody? body, CancelToken? cancelToken, ProgressCallback? onSendProgress, ProgressCallback? onReceiveProgress}) → Future<HttpTextResponse> - Makes an HTTP DELETE request and returns the response as text. Use requestBytes, or requestStream for other response types.
-
dispose(
{bool cancelRunningRequests = false}) → void - Disposes the client. This frees the resources associated with the client. After calling this method, the client should not be used anymore.
-
get(
String url, {Map< String, String> ? query, HttpHeaders? headers, CancelToken? cancelToken, ProgressCallback? onReceiveProgress}) → Future<HttpTextResponse> - Alias for getText.
-
getBytes(
String url, {Map< String, String> ? query, HttpHeaders? headers, CancelToken? cancelToken, ProgressCallback? onReceiveProgress}) → Future<HttpBytesResponse> - Makes an HTTP GET request and returns the response as bytes.
-
getStream(
String url, {Map< String, String> ? query, HttpHeaders? headers, CancelToken? cancelToken, ProgressCallback? onReceiveProgress}) → Future<HttpStreamResponse> - Makes an HTTP GET request and returns the response as a stream.
-
getText(
String url, {Map< String, String> ? query, HttpHeaders? headers, CancelToken? cancelToken, ProgressCallback? onReceiveProgress}) → Future<HttpTextResponse> - Makes an HTTP GET request and returns the response as text.
-
head(
String url, {Map< String, String> ? query, HttpHeaders? headers, CancelToken? cancelToken, ProgressCallback? onReceiveProgress}) → Future<HttpTextResponse> - Makes an HTTP HEAD request and returns the response as text. Use requestBytes, or requestStream for other response types.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
options(
String url, {Map< String, String> ? query, HttpHeaders? headers, HttpBody? body, CancelToken? cancelToken, ProgressCallback? onSendProgress, ProgressCallback? onReceiveProgress}) → Future<HttpTextResponse> - Makes an HTTP OPTIONS request and returns the response as text. Use requestBytes, or requestStream for other response types.
-
patch(
String url, {Map< String, String> ? query, HttpHeaders? headers, HttpBody? body, CancelToken? cancelToken, ProgressCallback? onSendProgress, ProgressCallback? onReceiveProgress}) → Future<HttpTextResponse> - Makes an HTTP PATCH request and returns the response as text. Use requestBytes, or requestStream for other response types.
-
post(
String url, {Map< String, String> ? query, HttpHeaders? headers, HttpBody? body, CancelToken? cancelToken, ProgressCallback? onSendProgress, ProgressCallback? onReceiveProgress}) → Future<HttpTextResponse> - Makes an HTTP POST request and returns the response as text. Use requestBytes, or requestStream for other response types.
-
put(
String url, {Map< String, String> ? query, HttpHeaders? headers, HttpBody? body, CancelToken? cancelToken, ProgressCallback? onSendProgress, ProgressCallback? onReceiveProgress}) → Future<HttpTextResponse> - Makes an HTTP PUT request and returns the response as text. Use requestBytes, or requestStream for other response types.
-
request(
{required HttpMethod method, required String url, Map< String, String> ? query, HttpHeaders? headers, HttpBody? body, required HttpExpectBody expectBody, CancelToken? cancelToken, ProgressCallback? onSendProgress, ProgressCallback? onReceiveProgress}) → Future<HttpResponse> - Makes an HTTP request. Use send if you already have a BaseHttpRequest object.
-
requestBytes(
{required HttpMethod method, required String url, Map< String, String> ? query, HttpHeaders? headers, HttpBody? body, CancelToken? cancelToken, ProgressCallback? onSendProgress, ProgressCallback? onReceiveProgress}) → Future<HttpBytesResponse> - Makes an HTTP request and returns the response as bytes.
-
requestStream(
{required HttpMethod method, required String url, Map< String, String> ? query, HttpHeaders? headers, HttpBody? body, CancelToken? cancelToken, ProgressCallback? onSendProgress, ProgressCallback? onReceiveProgress}) → Future<HttpStreamResponse> - Makes an HTTP request and returns the response as a stream.
-
requestText(
{required HttpMethod method, required String url, Map< String, String> ? query, HttpHeaders? headers, HttpBody? body, CancelToken? cancelToken, ProgressCallback? onSendProgress, ProgressCallback? onReceiveProgress}) → Future<HttpTextResponse> - Makes an HTTP request and returns the response as text.
-
send(
BaseHttpRequest request) → Future< HttpResponse> -
Similar to
request
, but uses a BaseHttpRequest object instead of individual parameters. -
toString(
) → String -
A string representation of this object.
inherited
-
trace(
String url, {Map< String, String> ? query, HttpHeaders? headers, HttpBody? body, CancelToken? cancelToken, ProgressCallback? onSendProgress, ProgressCallback? onReceiveProgress}) → Future<HttpTextResponse> - Makes an HTTP TRACE request and returns the response as text. Use requestBytes, or requestStream for other response types.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
create(
{ClientSettings? settings, List< Interceptor> ? interceptors}) → Future<RhttpClient> - Creates a new HTTP client asynchronously. Use this method if your app is already running to avoid blocking the UI.