pub struct ProxyConfig { /* private fields */ }
default-client
only.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
impl ProxyConfig
Sourcepub fn http<U>(proxy_url: U) -> Result<Self, ProxyError>
pub fn http<U>(proxy_url: U) -> Result<Self, ProxyError>
Sourcepub fn https<U>(proxy_url: U) -> Result<Self, ProxyError>
pub fn https<U>(proxy_url: U) -> Result<Self, ProxyError>
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")?;
Sourcepub fn all<U>(proxy_url: U) -> Result<Self, ProxyError>
pub fn all<U>(proxy_url: U) -> Result<Self, ProxyError>
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")?;
Sourcepub fn disabled() -> Self
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();
Sourcepub fn with_basic_auth<U, P>(self, username: U, password: P) -> Self
pub fn with_basic_auth<U, P>(self, username: U, password: P) -> Self
Add basic authentication to this proxy configuration
§Arguments
username
- Username for proxy authenticationpassword
- 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");
Sourcepub fn no_proxy<S: AsRef<str>>(self, rules: S) -> Self
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");
Sourcepub fn from_env() -> Self
pub fn from_env() -> Self
Create proxy configuration from environment variables
Reads standard proxy environment variables:
HTTP_PROXY
/http_proxy
: HTTP proxy URLHTTPS_PROXY
/https_proxy
: HTTPS proxy URLALL_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();
Sourcepub fn is_disabled(&self) -> bool
pub fn is_disabled(&self) -> bool
Check if proxy is disabled (no proxy configuration)
Sourcepub fn is_from_env(&self) -> bool
pub fn is_from_env(&self) -> bool
Check if this configuration uses environment variables
Trait Implementations§
Source§impl Clone for ProxyConfig
impl Clone for ProxyConfig
Source§fn clone(&self) -> ProxyConfig
fn clone(&self) -> ProxyConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl !Freeze for ProxyConfig
impl RefUnwindSafe for ProxyConfig
impl Send for ProxyConfig
impl Sync for ProxyConfig
impl Unpin for ProxyConfig
impl UnwindSafe for ProxyConfig
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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 more§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self
with the foreground set to
value
.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red()
and
green()
, which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg()
:
use yansi::{Paint, Color};
painted.fg(Color::White);
Set foreground color to white using white()
.
use yansi::Paint;
painted.white();
§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self
with the background set to
value
.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red()
and
on_green()
, which have the same functionality but
are pithier.
§Example
Set background color to red using fg()
:
use yansi::{Paint, Color};
painted.bg(Color::Red);
Set background color to red using on_red()
.
use yansi::Paint;
painted.on_red();
§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute
] value
.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold()
and
underline()
, which have the same functionality
but are pithier.
§Example
Make text bold using attr()
:
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);
Make text bold using using bold()
.
use yansi::Paint;
painted.bold();
§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi
[Quirk
] value
.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask()
and
wrap()
, which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk()
:
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);
Enable wrapping using wrap()
.
use yansi::Paint;
painted.wrap();
§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting()
due to conflicts with Vec::clear()
.
The clear()
method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting()
due to conflicts with Vec::clear()
.
The clear()
method will be removed in a future release.§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition
] value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted
only when both stdout
and stderr
are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);