# 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.

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

### `impl Proxy` [src]

#### `pub fn http<U: IntoProxyScheme>(proxy_scheme: U) -> Result<Proxy>` [src]

Proxy all HTTP traffic to the passed URL.

# Example

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

#### `pub fn https<U: IntoProxyScheme>(proxy_scheme: U) -> Result<Proxy>` [src]

Proxy all HTTPS traffic to the passed URL.

# Example

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

#### `pub fn all<U: IntoProxyScheme>(proxy_scheme: U) -> Result<Proxy>` [src]

Proxy all traffic to the passed URL.

# Example

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

#### `pub fn custom<F, U: IntoProxyScheme>(fun: F) -> Proxy where
F: Fn(&Url) -> Option<U> + Send + Sync + 'static,` [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()?;

#### `pub fn basic_auth(self, username: &str, password: &str) -> Proxy` [src]

Set the `Proxy-Authorization` header using Basic auth.

# Example

    let proxy = reqwest::Proxy::https("http://localhost:1234")?
        .basic_auth("Aladdin", "open sesame");

## Trait Implementations

### `impl Clone for Proxy` [src]

#### `fn clone(&self) -> Proxy` [src]

Returns a copy of the value. Read more

#### `pub fn clone_from(&mut self, source: &Self)`1.0.0 [src]

Performs copy-assignment from `source`. Read more

### `impl Debug for Proxy` [src]

#### `fn fmt(&self, f: &mut Formatter<'_>) -> Result` [src]

Formats the value using the given formatter. Read more

## 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

### `impl<T> Any for T where
T: 'static + ?Sized,` [src]

#### `pub fn type_id(&self) -> TypeId` [src]

Gets the `TypeId` of `self`. Read more

### `impl<T> Borrow<T> for T where
T: ?Sized,` [src]

#### `pub fn borrow(&self) -> &T` [src]

Immutably borrows from an owned value. Read more

### `impl<T> BorrowMut<T> for T where
T: ?Sized,` [src]

#### `pub fn borrow_mut(&mut self) -> &mut T` [src]

Mutably borrows from an owned value. Read more

### `impl<T> From<T> for T` [src]

#### `pub fn from(t: T) -> T` [src]

Performs the conversion.

### `impl<T> Instrument for T` [src]

#### `pub fn instrument(self, span: Span) -> Instrumented<Self>` [src]

Instruments this type with the provided `Span`, returning an `Instrumented` wrapper. Read more

#### `pub fn in_current_span(self) -> Instrumented<Self>` [src]

Instruments this type with the current `Span`, returning an `Instrumented` wrapper. Read more

### `impl<T, U> Into<U> for T where
U: From<T>,` [src]

#### `pub fn into(self) -> U` [src]

Performs the conversion.

### `impl<T> ToOwned for T where
T: Clone,` [src]

#### `type Owned = T`

The resulting type after obtaining ownership.

#### `pub fn to_owned(&self) -> T` [src]

Creates owned data from borrowed data, usually by cloning. Read more

#### `pub fn clone_into(&self, target: &mut T)` [src]

🔬 This is a nightly-only experimental API. (`toowned_clone_into`)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

### `impl<T, U> TryFrom<U> for T where
U: Into<T>,` [src]

#### `type Error = Infallible`

The type returned in the event of a conversion error.

#### `pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>` [src]

Performs the conversion.

### `impl<T, U> TryInto<U> for T where
U: TryFrom<T>,` [src]

#### `type Error = <U as TryFrom<T>>::Error`

The type returned in the event of a conversion error.

#### `pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>` [src]

Performs the conversion.