Skip to main content

ProxyConfig

Struct ProxyConfig 

Source
pub struct ProxyConfig { /* private fields */ }
Expand description

Proxy configuration for HTTP clients

Supports HTTP and HTTPS proxy configuration with authentication and bypass rules. Can be configured programmatically or automatically detected from environment variables.

§Examples

use aws_smithy_http_client::proxy::ProxyConfig;

// HTTP proxy for all traffic
let config = ProxyConfig::http("http://proxy.example.com:8080")?;

// HTTPS traffic through HTTP proxy (common case - no TLS needed for proxy connection)
let config = ProxyConfig::https("http://proxy.example.com:8080")?
    .with_basic_auth("username", "password")
    .no_proxy("localhost,*.internal");

// Detect from environment variables
let config = ProxyConfig::from_env();

Implementations§

Source§

impl ProxyConfig

Source

pub fn http<U>(proxy_url: U) -> Result<Self, ProxyError>
where U: TryInto<Uri>, U::Error: Display,

Create a new proxy configuration for HTTP traffic only

§Arguments
  • proxy_url - The HTTP proxy URL
§Examples
use aws_smithy_http_client::proxy::ProxyConfig;

let config = ProxyConfig::http("http://proxy.example.com:8080")?;
Source

pub fn https<U>(proxy_url: U) -> Result<Self, ProxyError>
where U: TryInto<Uri>, U::Error: Display,

Create a new proxy configuration for HTTPS traffic only

This proxy will only be used for https:// requests. HTTP requests will connect directly unless a separate HTTP proxy is configured.

The proxy URL itself can use either HTTP or HTTPS scheme:

  • http://proxy.example.com:8080 - Connect to proxy using HTTP (no TLS needed)
  • https://proxy.example.com:8080 - Connect to proxy using HTTPS (TLS required)

Note: If the proxy URL itself uses HTTPS scheme, TLS support must be available when building the connector, otherwise connections will fail.

§Arguments
  • proxy_url - The proxy URL
§Examples
use aws_smithy_http_client::proxy::ProxyConfig;

// HTTPS traffic through HTTP proxy (no TLS needed for proxy connection)
let config = ProxyConfig::https("http://proxy.example.com:8080")?;

// HTTPS traffic through HTTPS proxy (TLS needed for proxy connection)
let config = ProxyConfig::https("https://secure-proxy.example.com:8080")?;
Source

pub fn all<U>(proxy_url: U) -> Result<Self, ProxyError>
where U: TryInto<Uri>, U::Error: Display,

Create a new proxy configuration for all HTTP and HTTPS traffic

This proxy will be used for both http:// and https:// requests. This is equivalent to setting both HTTP and HTTPS proxies to the same URL.

Note: If the proxy URL itself uses HTTPS scheme, TLS support must be available when building the connector, otherwise connections will fail.

§Arguments
  • proxy_url - The proxy URL
§Examples
use aws_smithy_http_client::proxy::ProxyConfig;

let config = ProxyConfig::all("http://proxy.example.com:8080")?;
Source

pub fn disabled() -> Self

Create a proxy configuration that disables all proxy usage

This is useful for explicitly disabling proxy support even when environment variables are set.

§Examples
use aws_smithy_http_client::proxy::ProxyConfig;

let config = ProxyConfig::disabled();
Source

pub fn with_basic_auth<U, P>(self, username: U, password: P) -> Self
where U: Into<String>, P: Into<String>,

Add basic authentication to this proxy configuration

§Arguments
  • username - Username for proxy authentication
  • password - Password for proxy authentication
§Examples
use aws_smithy_http_client::proxy::ProxyConfig;

let config = ProxyConfig::http("http://proxy.example.com:8080")?
    .with_basic_auth("username", "password");
Source

pub fn no_proxy<S: AsRef<str>>(self, rules: S) -> Self

Add NO_PROXY rules to this configuration

NO_PROXY rules specify hosts that should bypass the proxy and connect directly.

§Arguments
  • rules - Comma-separated list of bypass rules
§Examples
use aws_smithy_http_client::proxy::ProxyConfig;

let config = ProxyConfig::http("http://proxy.example.com:8080")?
    .no_proxy("localhost,127.0.0.1,*.internal,10.0.0.0/8");
Source

pub fn from_env() -> Self

Create proxy configuration from environment variables

Reads standard proxy environment variables:

  • HTTP_PROXY / http_proxy: HTTP proxy URL
  • HTTPS_PROXY / https_proxy: HTTPS proxy URL
  • ALL_PROXY / all_proxy: Proxy for all protocols (fallback)
  • NO_PROXY / no_proxy: Comma-separated bypass rules

If no proxy environment variables are set, this returns a configuration that won’t intercept any requests (equivalent to no proxy).

§Examples
use aws_smithy_http_client::proxy::ProxyConfig;

// Always succeeds, even if no environment variables are set
let config = ProxyConfig::from_env();
Source

pub fn is_disabled(&self) -> bool

Check if proxy is disabled (no proxy configuration)

Source

pub fn is_from_env(&self) -> bool

Check if this configuration uses environment variables

Trait Implementations§

Source§

impl Clone for ProxyConfig

Source§

fn clone(&self) -> ProxyConfig

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ProxyConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

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

fn in_current_span(self) -> Instrumented<Self> ⓘ

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

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more