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, ornull. Expired entries are returned only whenallowStaleis 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 foruri. -
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
uriand returns the full ProxyResolution (source, PAC URL, error). Served from the cache when a fresh entry exists unlessforceRefreshis 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