pub struct WinHttpPacResolver { /* private fields */ }pac-windows-native and crate feature pac only.Expand description
PAC/WPAD via WinHttpGetProxyForUrlEx. Reuse one session; the cache it does not
bound is described on resolve.
Pac / WpadAutoDetect: native fetch.
PacInline: pac-boa. Direct/Manual: resolve_config.
resolve_config answers a hostless URL Direct, except
PacInline: that one is Error::PacNotSupported whether or not
the URL has a host. resolve does not short-circuit it — see its doc.
PacPolicy does not apply — real DNS/local IP.
Implementations§
Source§impl WinHttpPacResolver
impl WinHttpPacResolver
Sourcepub fn new() -> Result<Self, Error>
pub fn new() -> Result<Self, Error>
Open a session with the default DEFAULT_WINHTTP_PAC_TIMEOUT budget.
§Errors
Error::Io when WinHttpOpen, WinHttpSetTimeouts or
WinHttpSetStatusCallback fails.
Sourcepub fn with_timeout(timeout: Duration) -> Result<Self, Error>
pub fn with_timeout(timeout: Duration) -> Result<Self, Error>
Open a session; zero timeout → Error::PacTimeout (not “unlimited”).
§Errors
Error::Io (WinHttpOpen / SetTimeouts / SetStatusCallback) or
Error::PacTimeout when timeout is zero.
Sourcepub fn resolve(
&self,
url: &Url,
source: &WinHttpPacSource,
) -> Result<Vec<ProxyStep>, Error>
pub fn resolve( &self, url: &Url, source: &WinHttpPacSource, ) -> Result<Vec<ProxyStep>, Error>
Resolve url via source. Full FindProxyForURL chain → ProxySteps
(HTTP/HTTPS/SOCKS4; fProxy == FALSE → Direct; FTP skipped; repeats collapse,
as in parse_find_proxy_result, so the chain can
be shorter than the entry count WinHTTP reported).
ERROR_WINHTTP_AUTODETECTION_FAILED → [Direct], but only from a source that
asked for auto-detect. Download / script failure — and that same code from a
URL-only source, where there was nothing to discover — stays an error.
A hostless URL (mailto:, data:) is resolved rather than short-circuited: this is
the engine door, the native counterpart of pac::evaluate, and
FindProxyForURL sees it with an empty host. Answering Direct without asking belongs
to resolve_config, which was handed a whole configuration to
decide from rather than a source the caller had already chosen.
Asking twice can be answered once. What WinHTTP caches is the autoproxy URL and the
script — a repeat resolution re-runs that script rather than fetching it again, and
a WPAD miss is remembered for as long as the session lives. The call that would
bypass the cache is deliberately not made: it hands the user’s credentials to
whatever WPAD found. Nothing here flushes it, and neither does dropping the
resolver: WinHttpGetProxyForUrlEx “always executes out-of-process”, and with that
service active Microsoft’s AutoProxy Cache topic puts the cached URL and script
“available to the whole computer” — typically until the machine’s IP address
changes, which no caller controls. Unlike ProxyConfig the result carries no
capture time to say which fetch it came from.
A PacTimeout cancels the resolution without finishing it: the
abandoned operation goes on draining behind this session, and a retry issued at once
can spend its own budget waiting behind that rather than on the script. Widen the
timeout or wait before retrying.
§Errors
Error::PacTimeout, Error::PacEvaluation
(ERROR_WINHTTP_BAD_AUTO_PROXY_SCRIPT), Error::PacInvalidResult,
Error::Io (incl. undownloadable PAC URL).
Sourcepub fn resolve_config(
&self,
config: &ProxyConfig,
url: &Url,
) -> Result<Vec<ProxyStep>, Error>
pub fn resolve_config( &self, config: &ProxyConfig, url: &Url, ) -> Result<Vec<ProxyStep>, Error>
Like resolve_with_pac but WinHTTP fetches the script.
Direct/Manual → resolve; hostless → Direct except
PacInline → Error::PacNotSupported.
WpadAutoDetect may re-read the live registry for
PAC URL / static fallback — not a pure function of config alone.
§Errors
Error::PacNotSupported for PacInline, plus resolve’s errors —
and, for the Direct/Manual arm this hands over, resolve’s, which
is where Error::ProxyEntryUnusable comes from.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for WinHttpPacResolver
impl RefUnwindSafe for WinHttpPacResolver
impl Send for WinHttpPacResolver
impl Sync for WinHttpPacResolver
impl Unpin for WinHttpPacResolver
impl UnsafeUnpin for WinHttpPacResolver
impl UnwindSafe for WinHttpPacResolver
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.