Struct reqwest_dav::re_exports::reqwest::Proxy
source · [−]pub struct Proxy { /* private fields */ }
Expand description
Configuration of a proxy that a Client
should pass requests to.
A Proxy
has a couple pieces to it:
- a URL of how to talk to the proxy
- rules on what
Client
requests should be directed to the proxy
For instance, let’s look at Proxy::http
:
let proxy = reqwest::Proxy::http("https://secure.example")?;
This proxy will intercept all HTTP requests, and make use of the proxy
at https://secure.example
. A request to http://hyper.rs
will talk
to your proxy. A request to https://hyper.rs
will not.
Multiple Proxy
rules can be configured for a Client
. The Client
will
check each Proxy
in the order it was added. This could mean that a
Proxy
added first with eager intercept rules, such as Proxy::all
,
would prevent a Proxy
later in the list from ever working, so take care.
By enabling the "socks"
feature it is possible to use a socks proxy:
let proxy = reqwest::Proxy::http("socks5://192.168.1.1:9000")?;
Implementations
sourceimpl Proxy
impl Proxy
sourcepub fn http<U>(proxy_scheme: U) -> Result<Proxy, Error>where
U: IntoProxyScheme,
pub fn http<U>(proxy_scheme: U) -> Result<Proxy, Error>where
U: IntoProxyScheme,
Proxy all HTTP traffic to the passed URL.
Example
let client = reqwest::Client::builder()
.proxy(reqwest::Proxy::http("https://my.prox")?)
.build()?;
sourcepub fn https<U>(proxy_scheme: U) -> Result<Proxy, Error>where
U: IntoProxyScheme,
pub fn https<U>(proxy_scheme: U) -> Result<Proxy, Error>where
U: IntoProxyScheme,
Proxy all HTTPS traffic to the passed URL.
Example
let client = reqwest::Client::builder()
.proxy(reqwest::Proxy::https("https://example.prox:4545")?)
.build()?;
sourcepub fn all<U>(proxy_scheme: U) -> Result<Proxy, Error>where
U: IntoProxyScheme,
pub fn all<U>(proxy_scheme: U) -> Result<Proxy, Error>where
U: IntoProxyScheme,
Proxy all traffic to the passed URL.
Example
let client = reqwest::Client::builder()
.proxy(reqwest::Proxy::all("http://pro.xy")?)
.build()?;
sourcepub fn custom<F, U>(fun: F) -> Proxywhere
U: IntoProxyScheme,
F: 'static + Fn(&Url) -> Option<U> + Send + Sync,
pub fn custom<F, U>(fun: F) -> Proxywhere
U: IntoProxyScheme,
F: 'static + Fn(&Url) -> Option<U> + Send + Sync,
Provide a custom function to determine what traffic to proxy to where.
Example
let target = reqwest::Url::parse("https://my.prox")?;
let client = reqwest::Client::builder()
.proxy(reqwest::Proxy::custom(move |url| {
if url.host_str() == Some("hyper.rs") {
Some(target.clone())
} else {
None
}
}))
.build()?;
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Proxy
impl Send for Proxy
impl Sync for Proxy
impl Unpin for Proxy
impl !UnwindSafe for Proxy
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T>where
T: Future, type Output = <T as Future>::Output;
fn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T>where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
sourcefn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T>where
T: Future, type Output = <T as Future>::Output;
fn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T>where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
impl<V, T> VZip<V> for Twhere
V: MultiLane<T>,
impl<V, T> VZip<V> for Twhere
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T>where
T: Future, type Output = <T as Future>::Output;
where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T>where
T: Future, type Output = <T as Future>::Output;
where
S: Into<Dispatch>,
T: Future, type Output = <T as Future>::Output;
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T>where
T: Future, type Output = <T as Future>::Output;
fn with_current_subscriber(self) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T>where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more