Skip to main content

sleek_http_client 1.4.0 copy "sleek_http_client: ^1.4.0" to clipboard
sleek_http_client: ^1.4.0 copied to clipboard

A sleek, pure-Dart HTTP client with connectivity checking, token refresh, multipart support, and structured logging.

Changelog #

1.4.0 #

  • Added SleekHttpClient.abortAll(): aborts every request in flight on the client (retries and a token refresh in progress included), e.g. on logout. Aborted calls throw RequestAbortedException, now re-exported from package:http. Requests sent afterwards are not affected.
  • A timeout now really aborts the underlying request instead of only ceasing to wait for it, so the connection no longer keeps running in the background. The exception thrown is still ConnectivityException(timeout), and a retry after a timeout starts with a fresh timeout.
  • copyAsNew() keeps the abort link of the original request, so a retry cannot outlive an abortAll().
  • LoggingInterceptor logs a call cancelled by abortAll() on a 🚫 line (aborted) instead of a ❌ line with the exception.

1.3.0 #

  • Added per-request extra: send / sendMultipartRequest accept extra: {...}, readable in interceptors via request.extra[key] (new RequestExtra extension on http.BaseRequest). It is never sent as an HTTP header, and is copied by copyAsNew() so it survives a retry.
  • BREAKING (log format) LoggingInterceptor now logs one message per call (status icon, duration, bodies on their own lines, host in a [label]) instead of one line for the request and one for the response. The [SleekHttp] prefix is gone and bodies are cut after 500 characters. See the README for the new format.
  • Added LoggingInterceptor options layout, labelBuilder, leading, logRequests and maxBodyLength.
  • example/main.dart: new scenario showing the LoggingInterceptor output.
  • authorityGetter is now optional: the authority can be passed per call instead. A StateError is thrown when a request is built with neither.
  • sendMultipartRequest now accepts a per-call authority, like send.

1.2.0 #

  • LoggingInterceptor now also logs exceptions thrown down the chain instead of a response (no internet, timeout, DNS / connection failure, ...) on a ❌ line, then rethrows them unchanged.
  • Fixed send<void>() / send<Null>() / send<Object?>() throwing UnimplementedError (after the request was processed by the server) instead of resolving to null.
  • Fixed the timeout not covering the request sending phase (only the body reading): a server that never sent its headers could block a request until the OS-level TCP timeout.
  • Fixed a deadlock in TokenRefreshInterceptor when the refresh callback sends its request through the same client after an await (or behind an asynchronous interceptor): requests to excludedPaths no longer wait for the in-flight refresh.
  • An empty success body is now treated like a JSON null for JsonObject/JsonList: send<JsonObject?>() resolves to null, send<JsonObject>() throws NullResponseBodyException (previously both threw a FormatException).

1.1.0 #

  • Added JsonHttpResponse extension on http.Response (isJson, decodeJson<T>(), tryDecodeJson<T>()) so JSON response helpers can be used on any http.Response, not just those produced by SleekHttpClient.

1.0.0 #

  • BREAKING Replaced HttpRetryPolicy / HttpRetryPolicyBuilder / TokenRefreshHandler and HttpClientLogConfig (logConfig) with a single composable HttpInterceptor chain (SleekHttpClient.interceptors), including TokenRefreshInterceptor and LoggingInterceptor.
  • BREAKING send<T>/sendMultipartRequest<T> now return T instead of T?. T's own nullability drives behavior for JsonObject/JsonList: send<JsonObject>() requires a non-null body and throws the new NullResponseBodyException if the server returns JSON null, while send<JsonObject?>() returns null in that case. A malformed body or unexpected JSON shape always throws (FormatException/TypeError), regardless of nullability — it is no longer silently swallowed to null.

0.1.0 #

  • Initial release
1
likes
160
points
976
downloads

Documentation

API reference

Publisher

verified publishericysun.fr

Weekly Downloads

A sleek, pure-Dart HTTP client with connectivity checking, token refresh, multipart support, and structured logging.

Repository (GitHub)
View/report issues

License

BSD-3-Clause (license)

Dependencies

connectivity_plus, http

More

Packages that depend on sleek_http_client