rhttp library
Classes
- BaseHttpRequest
- An HTTP request that can be used on a client or statically.
- CancelToken
- A token that can be used to cancel an HTTP request. This token should be passed to the request method.
- ClientCertificate
- A client certificate for client authentication / mutual TLS.
- ClientSettings
- CookieSettings
- Cookie settings for the client. Used to configure Cookie handling.
- CustomProxy
- DnsSettings
- HttpBody
- HttpBodyBytes
- A body of raw bytes.
- HttpBodyBytesStream
- A body of a raw bytes stream. This is useful to avoid loading the entire body into memory. The Content-Length header will be set if length is provided.
- HttpBodyForm
-
A www-form-urlencoded body.
The Content-Type header will be set to
application/x-www-form-urlencoded
if not provided. - HttpBodyJson
-
A JSON body.
The Content-Type header will be set to
application/json
if not provided. - HttpBodyMultipart
-
Multi-part form data.
The Content-Type header will be overridden to
multipart/form-data
with a random boundary. - HttpBodyText
- A plain text body.
- HttpBytesResponse
- HttpHeaderList
- A raw header list. This allows for multiple headers with the same name.
- HttpHeaderMap
- A typed header map with a set of predefined keys.
- HttpHeaderRawMap
- A raw header map where the keys are strings.
- HttpHeaders
- HttpMethod
- The HTTP method to use.
- HttpRequest
- An HTTP request with the information which client to use.
- HttpResponse
- HttpStreamResponse
- HttpTextResponse
- Interceptor
- An interceptor that can be used to modify requests / responses, handle errors, observe requests, etc.
-
InterceptorNextResult<
T> - Continues to the next interceptor. If no value is provided, the current value is returned (no changes).
-
InterceptorResolveResult<
T> - Stops the interceptor chain and resolve the request with a response.
-
InterceptorResult<
T> -
InterceptorStopResult<
T> - Stops the interceptor chain. If no value is provided, the current value is returned (no changes).
- IoCompatibleClient
-
An HTTP client that is compatible with dart:io package.
This minimizes the changes needed to switch from dart:io to
rhttp
and also avoids vendor lock-in. - MultiPartBytes
- A value of raw bytes.
- MultiPartFile
- A file path.
- MultipartItem
- MultiPartText
- A plain text value.
- ProxySettings
- RedirectSettings
- RetryInterceptor
- An interceptor that retries requests if they fail.
- Rhttp
- RhttpCancelException
- An exception thrown when a request is canceled.
- RhttpClient
- 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.
- RhttpClientDisposedException
- An exception thrown a request is made with an invalid client.
- RhttpCompatibleClient
-
An HTTP client that is compatible with the
http
package. This minimizes the changes needed to switch fromhttp
torhttp
and also avoids vendor lock-in. - RhttpConnectionException
- An exception thrown when a connection error occurs. For example, when the server is unreachable or internet is not available.
- RhttpException
-
The base class for all exceptions thrown by the
rhttp
library or by interceptors. - RhttpInterceptorException
- An exception thrown by an interceptor. Interceptors should only throw exceptions of type RhttpException.
- RhttpInvalidCertificateException
- An exception thrown when the server's certificate is invalid.
- RhttpRedirectException
- An exception thrown when there are issues related to redirects.
- RhttpStatusCodeException
- An exception thrown on a 4xx or 5xx status code.
- RhttpTimeoutException
- An exception thrown when a request times out.
- RhttpUnknownException
- An exception thrown when an unknown error occurs.
- SequentialInterceptor
- An interceptor that queues other interceptors sequentially.
- SimpleInterceptor
- An interceptor where you can specify the behavior in the constructor without creating a new class.
- StaticProxy
- TimeoutSettings
- General timeout settings for the client.
- TlsSettings
- TLS settings for the client. Used to configure HTTPS connections.
Enums
- CancelState
- HttpExpectBody
- HttpHeaderName
- Type safe representation of HTTP headers.
- HttpVersion
- HttpVersionPref
- ProxyCondition
Typedefs
-
BeforeRetry
= Future<
HttpRequest?> Function(int attempt, HttpRequest request, HttpResponse? response, RhttpException? exception) - ProgressCallback = void Function(int count, int total)
-
A callback that can be used to report progress.
count
is the current count of bytes received / sent.total
is the total count of bytes to receive / send.total
might be -1 when it is unknown (e.g. missing Content-Length header). - RetryCondition = bool Function(HttpResponse?, RhttpException?)
- RetryDelay = Duration Function(int)
Exceptions / Errors
- RhttpWrappedClientException
-
Every exception must be a subclass of
ClientException
as per contract ofBaseClient
.