SystemProxyResolver class

Resolves proxies through the operating system, with an origin-keyed TTL cache, request de-duplication and automatic invalidation on network or proxy changes.

The cache key is the URL origin (scheme://host:port). PAC scripts may in theory branch on the URL path; such rules are only re-evaluated once the cached origin entry expires.

Constructors

SystemProxyResolver({NativeProxyResolverPlatform? platform, Duration cacheTtl = const Duration(minutes: 5), Duration errorTtl = const Duration(seconds: 30), Duration timeout = const Duration(seconds: 10), int maxCacheEntries = 256, bool invalidateOnChange = true, DateTime clock()?})
Creates a resolver.

Properties

cacheSize → int
Number of cached origins (fresh or stale).
no setter
cacheTtl → Duration
How long a successful resolution is cached.
final
errorTtl → Duration
How long a failed resolution is cached.
final
hashCode → int
The hash code for this object.
no setterinherited
invalidateOnChange → bool
Whether change events clear the cache.
final
maxCacheEntries → int
Maximum number of cached origins.
final
onChange → Stream<void>
Emits when the platform reports a network or proxy change (see NativeProxyResolverPlatform.supportsChangeEvents).
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
supportsChangeEvents → bool
Whether onChange delivers events on this platform.
no setter
timeout → Duration
Upper bound for one native resolution.
final

Methods

cached(Uri uri, {bool allowStale = false}) → ProxyResolution?
The cached resolution for uri's origin, or null. Expired entries are returned only when allowStale is true.
clearCache() → void
Removes every cached resolution.
dispose() → Future<void>
Stops listening for change events and clears the cache. The resolver cannot be used afterwards.
findProxy(Uri uri, {String fallback = 'DIRECT', bool resolveOnMiss = true}) → String
A synchronous HttpClient.findProxy-compatible answer for uri.
findProxyCallback({String fallback = 'DIRECT'}) → String Function(Uri)
A closure suitable for HttpClient.findProxy.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
resolve(Uri uri, {bool forceRefresh = false}) → Future<List<ProxyEntry>>
Resolves the ordered proxy list for uri. Never empty; [DIRECT] when no proxy applies or resolution failed (see resolveDetailed for the reason).
resolveDetailed(Uri uri, {bool forceRefresh = false}) → Future<ProxyResolution>
Resolves uri and returns the full ProxyResolution (source, PAC URL, error). Served from the cache when a fresh entry exists unless forceRefresh is true.
toString() → String
A string representation of this object.
inherited
warmUp(Iterable<Uri> uris) → Future<void>
Resolves several URLs in parallel so later synchronous findProxy calls hit the cache.

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

cacheKey(Uri uri) → String
The cache key for uri: scheme://host:port with ws/wss folded into http/https.