json_rest_client 0.2.0
json_rest_client: ^0.2.0 copied to clipboard
A small, dependency-light JSON HTTP client with typed exceptions, pluggable auth token storage, user-agent injection, and refresh-on-401 retry with a single-flight refresh lock.
0.2.0 - 2026-10-16 #
- Added
RetryPolicywith exponential backoff, jitter, exactRetry-Aftersupport, per-status retry rules, and aretryNonIdempotentopt-in. - The client retries network failures and retryable statuses for
GET,HEAD,PUT, andDELETE; timeouts are never retried. - Added sync
onRequest,onResponse, andonErrorinterceptor hooks that fire once per HTTP exchange, including retry and refresh attempts. - Added tests for the per-call timeout override on
getandsendRaw.
0.1.3 #
- Documentation and internal cleanup.
0.1.2 #
- Rewrite the README. Document
sendRaw,RestResponse,ResponseLimitException, and the refresh rules.
0.1.1 #
RestClientExceptionand every subtype now expose thestatusCodeandheadersof the response that caused the failure, when one exists.- Added
RestResponseandJsonRestClient.sendRawfor status-and-bytes access without JSON decoding or error mapping. - Added
ResponseLimitException, thrown bysendRawwhen a response body exceedsmaxResponseBytes; the body stream is abandoned as soon as the limit is crossed.
0.1.0 #
- Initial release: extracted the app's networking layer into a standalone, pure-Dart package.
- Added
JsonRestClientwithgetandposthelpers that JSON-decode responses and returnnullfor empty successful bodies. - Added typed exceptions (
RestClientExceptionand its subtypes) for network, timeout, HTTP status, and deserialization failures. - HTTP status exceptions carry the raw response body as
message, falling back to'HTTP <status>'only when the body is empty. - Errors thrown by caller-supplied callbacks (
decoder,onUnauthorized,tokenStore,userAgentProvider) and JSON-encoding failures of an unsupportedbodypropagate unchanged. - Added single-flight refresh on
401/403: the token returned byonUnauthorizedis used for exactly one retry, and a missing token or a still-unauthorized retry raisesUnauthorizedException. - Request paths resolve relative to
baseUrl, ignoring a leading/. - Headers merge case-insensitively in the order
defaultHeaders, computeduser-agent/authorization, then per-callheaders; per-call values win. close()releases the internally createdhttp.Clientonly; injected clients remain the caller's responsibility.- Pure-Dart scope using
dart:ioforSocketException, so the package targets mobile, desktop, and server apps (not web).