Struct reqwest::Proxy [] [src]

pub struct Proxy { /* fields omitted */ }

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.

Methods

impl Proxy
[src]

[src]

Proxy all HTTP traffic to the passed URL.

Example

let client = reqwest::Client::builder()
    .proxy(reqwest::Proxy::http("https://my.prox")?)
    .build()?;

[src]

Proxy all HTTPS traffic to the passed URL.

Example

let client = reqwest::Client::builder()
    .proxy(reqwest::Proxy::https("https://example.prox:4545")?)
    .build()?;

[src]

Proxy all traffic to the passed URL.

Example

let client = reqwest::Client::builder()
    .proxy(reqwest::Proxy::all("http://pro.xy")?)
    .build()?;

[src]

Provide a custom function to determine what traffix 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

impl Clone for Proxy
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for Proxy
[src]

[src]

Formats the value using the given formatter.