json_rest_client 0.1.1
json_rest_client: ^0.1.1 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.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).