basic_http_interceptor library
Lightweight, pluggable HTTP interceptors for logging, default headers, functional hooks, proxy configurations, and request timeout abortion.
Classes
- DirectoryQuotaManager
- A decoupled, directory-agnostic disk quota manager and LRU cache evictor.
- InterceptedClient
-
Class to be used by the user to set up a new
http.Clientwith interceptor support. - InterceptorContract
- Interceptor interface to create custom Interceptor for http. Extend this class and override the functions that you want to intercept.
- InterceptorHeader
- An interceptor that attaches a predefined set of HTTP headers to every outgoing request.
- InterceptorHook
- An interceptor that transforms requests and responses using custom callback functions.
- InterceptorLogger
-
An interceptor that logs HTTP requests and responses using the
loggingpackage. - InterceptorTimeout
-
An interceptor that enforces a physical connection timeout on HTTP requests using
Abortable. - MethodSwitchingClient
- A client wrapper that dynamically routes requests between HTTP clients based on request type and content.
- UrlFileCache
- UrlFileCache
Enums
- LruSortStrategy
- DirectoryQuotaManager
Functions
-
buildUrlString(
String url, Map< String, dynamic> ? parameters) → String -
Takes a string and appends
parametersas query parameters ofurl. -
inferAuthorizationHeaderValue(
String authorization) → String - Infers and adds an authorization scheme to an untyped authorization token.
-
interceptedClient(
{required List< InterceptorContract> interceptors, Map<String, String> proxy = const {}}) → InterceptedClient -
Creates an InterceptedClient configured with the given
interceptorsand optionalproxysettings. -
isBase64Credentials(
String base64String) → bool -
Validates whether
base64Stringdecodes to ausername:passwordpair. -
isJwt(
String token) → bool -
Validates whether
tokenhas the structural format of a JSON Web Token. -
loadUriText(
Uri uri, {Directory? cacheDir, UrlFileCache? fileCache, Client? client, Duration? ttl, bool forceRefresh = false}) → Future< String> - Companion helper function to fetch plain text (UTF-8 string) from a Uri.
-
normalizeAuthorizationHeaders(
Map< String, String> headers) → Map<String, String> -
Returns a copy of
headerswith its Authorization header normalized. -
proxyClient(
{Map< String, String> headers = const {}, Map<String, String> proxy = const {}, List<InterceptorContract> interceptors = const [], Duration? timeout, Logger? logger}) → InterceptedClient - Creates an HTTP client configured with custom interceptors, request headers, a request timeout, and a proxy.
Typedefs
- TimeoutCallback = void Function(BaseRequest request)