HttpClient class

Mercury HTTP Client.

Constructors

HttpClient(String baseURL, [HttpClientRequester? clientRequester])

Properties

authorization Authorization?
The Authorization (that resolves Credential) for requests.
getter/setter pair
authorizationResolutionInterceptor AuthorizationInterceptor?
getter/setter pair
baseURL String
The base URL for the client requests.
getter/setter pair
clientRequester HttpClientRequester
Returns the HttpClientRequester instance.
no setter
crossSiteWithCredentials bool?
If set to true, sends credential to cross sites.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
hasInterceptor bool
Returns true if has an interceptor.
no setter
id int
ID of this client.
final
interceptor HttpClientInterceptor?
An optional interceptor, that can be used to log requests or to change headers and URLs.
getter/setter pair
isAuthorizationResolved bool
Returns true if authorization is resolved.
no setter
jsonDecoder ↔ dynamic Function(String jsonEncoded)?
The JSON decoder. Default: dart:convert json
getter/setter pair
logJSON bool
getter/setter pair
logRequests bool
getter/setter pair
requestHeadersBuilder RequestHeadersBuilder?
Builds initial headers for each request.
getter/setter pair
resolvedAuthorization Authorization?
Returns the authorization if is resolved.
no setter
responseHeaderWithToken String?
The response header with a token to use as authorization Credential.
no setter
responseProcessor ResponseProcessor?
Function that processes any request response.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
urlFilter HttpClientURLFilter?
The URL filter, if present.
getter/setter pair
userAgent String?
getter/setter pair

Methods

autoChangeAuthorizationToBearerToken(String responseHeaderWithToken) HttpClient
If set, will automatically use a token in the header responseHeaderWithToken, when found in any request.
buildMethodRequestURL(HttpMethod method, String? path, bool fullPath, Map<String, String?>? parameters) String
Builds the URL for method using path or fullPath.
buildRequestHeaders(String url) Map<String, String>?
buildRequestURL(HttpMethod method, String path, {bool fullPath = false, Authorization? authorization, Map<String, Object?>? parameters, String? queryString, bool noQueryString = false}) String
Builds a Request URL, with the same rules of requestURL.
buildURL(String path, bool fullPath, [Map<String, String?>? queryParameters, bool allowURLQueryString = true]) String
Builds a URL, using baseURL with path or fullPath.
delete(String path, {Map<String, String>? headers, bool fullPath = false, Credential? authorization, Map<String, String?>? parameters, String? queryString, Object? body, String? contentType, String? accept, String? responseType, ProgressListener? progressListener}) Future<HttpResponse>
Does a DELETE request.
get(String path, {Map<String, String>? headers, bool fullPath = false, Credential? authorization, Map<String, Object?>? parameters, String? accept, String? responseType, ProgressListener? progressListener}) Future<HttpResponse>
/////////// Does a GET request.
getJSON(String path, {Map<String, String>? headers, Credential? authorization, Map<String, Object?>? parameters}) Future
Does a GET request and returns a decoded JSON.
Does a HEAD request.
isBaseUrlLocalhost() bool
Returns true if this baseURL is localhost.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
options(String path, {Map<String, String>? headers, bool fullPath = false, Credential? authorization, Map<String, Object?>? parameters, ProgressListener? progressListener}) Future<HttpResponse>
Does an OPTIONS request.
optionsJSON(String path, {Map<String, String>? headers, Credential? authorization, Map<String, Object?>? parameters}) Future
Does an OPTION request and returns a decoded JSON.
patch(String path, {Map<String, String>? headers, bool fullPath = false, Credential? authorization, Map<String, Object?>? parameters, String? queryString, Object? body, String? contentType, String? accept, String? responseType, ProgressListener? progressListener}) Future<HttpResponse>
Does a PATCH request.
post(String path, {Map<String, String>? headers, bool fullPath = false, Credential? authorization, Map<String, Object?>? parameters, String? queryString, Object? body, String? contentType, String? accept, String? responseType, ProgressListener? progressListener}) Future<HttpResponse>
Does a POST request.
postJSON(String path, {Map<String, String>? headers, Credential? authorization, Map<String, Object?>? parameters, Object? body, String? contentType}) Future
Does a POST request and returns a decoded JSON.
put(String path, {Map<String, String>? headers, bool fullPath = false, Credential? authorization, Map<String, Object?>? parameters, String? queryString, Object? body, String? contentType, String? accept, String? responseType, ProgressListener? progressListener}) Future<HttpResponse>
Does a PUT request.
putJSON(String path, {Map<String, String>? headers, Credential? authorization, Object? body, String? contentType}) Future
Does a PUT request and returns a decoded JSON.
request(HttpMethod method, String path, {bool fullPath = false, Map<String, String>? headers, Credential? authorization, Map<String, Object?>? parameters, String? queryString, Object? body, String? contentType, String? accept, bool noQueryString = false, ProgressListener? progressListener}) Future<HttpResponse>
Does a request using method.
requestJSON(HttpMethod method, String path, {Map<String, String>? headers, Credential? authorization, Map<String, Object?>? queryParameters, Object? body, String? contentType, String? accept}) Future
Requests using method and path and returns a decoded JSON.
requestURL(HttpMethod method, String url, {Map<String, String>? headers, Credential? authorization, Map<String, Object?>? queryParameters, dynamic noQueryString = false, Object? body, String? contentType, String? accept, ProgressListener? progressListener}) Future<HttpResponse>
toString() String
A string representation of this object.
override
withBasePath(String basePath) HttpClient
Returns a new HttpClient instance using basePath as path of baseURL.
withBaseURL(String baseURL, {bool preserveAuthorization = false}) HttpClient
Returns a new HttpClient instance using baseURL.

Operators

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