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.Client with 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 logging package.
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 parameters as query parameters of url.
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 interceptors and optional proxy settings.
isBase64Credentials(String base64String) → bool
Validates whether base64String decodes to a username:password pair.
isJwt(String token) → bool
Validates whether token has 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 headers with 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)