Struct hyper_rustls::HttpsConnectorBuilder

source ·
pub struct HttpsConnectorBuilder<State>(/* private fields */);
Expand description

A builder for an HttpsConnector

This makes configuration flexible and explicit and ensures connector features match crate features

§Examples

use hyper_rustls::HttpsConnectorBuilder;

    let https = HttpsConnectorBuilder::new()
    .with_webpki_roots()
    .https_only()
    .enable_http1()
    .build();

Implementations§

source§

impl ConnectorBuilder<WantsTlsConfig>

source

pub fn new() -> Self

Creates a new ConnectorBuilder

source

pub fn with_tls_config( self, config: ClientConfig, ) -> ConnectorBuilder<WantsSchemes>

Passes a rustls ClientConfig to configure the TLS connection

The alpn_protocols field is required to be empty (or the function will panic) and will be rewritten to match the enabled schemes (see enable_http1, enable_http2) before the connector is built.

source§

impl ConnectorBuilder<WantsSchemes>

source

pub fn https_only(self) -> ConnectorBuilder<WantsProtocols1>

Enforce the use of HTTPS when connecting

Only URLs using the HTTPS scheme will be connectable.

source

pub fn https_or_http(self) -> ConnectorBuilder<WantsProtocols1>

Allow both HTTPS and HTTP when connecting

HTTPS URLs will be handled through rustls, HTTP URLs will be handled by the lower-level connector.

source§

impl ConnectorBuilder<WantsProtocols1>

source

pub fn enable_http1(self) -> ConnectorBuilder<WantsProtocols2>

Enable HTTP1

This needs to be called explicitly, no protocol is enabled by default

source

pub fn enable_http2(self) -> ConnectorBuilder<WantsProtocols3>

Enable HTTP2

This needs to be called explicitly, no protocol is enabled by default

source

pub fn enable_all_versions(self) -> ConnectorBuilder<WantsProtocols3>

Enable all HTTP versions built into this library (enabled with Cargo features)

For now, this could enable both HTTP 1 and 2, depending on active features. In the future, other supported versions will be enabled as well.

source

pub fn with_server_name_resolver( self, resolver: impl ResolveServerName + 'static + Sync + Send, ) -> Self

Override server name for the TLS stack

By default, for each connection hyper-rustls will extract host portion of the destination URL and verify that server certificate contains this value.

If this method is called, hyper-rustls will instead use this resolver to compute the value used to verify the server certificate.

source

pub fn with_server_name(self, override_server_name: String) -> Self

👎Deprecated since 0.27.1: use Self::with_server_name_resolver with FixedServerNameResolver instead

Override server name for the TLS stack

By default, for each connection hyper-rustls will extract host portion of the destination URL and verify that server certificate contains this value.

If this method is called, hyper-rustls will instead verify that server certificate contains override_server_name. Domain name included in the URL will not affect certificate validation.

source§

impl ConnectorBuilder<WantsProtocols2>

source

pub fn enable_http2(self) -> ConnectorBuilder<WantsProtocols3>

Enable HTTP2

This needs to be called explicitly, no protocol is enabled by default

source

pub fn build(self) -> HttpsConnector<HttpConnector>

This builds an HttpsConnector built on hyper’s default HttpConnector

source

pub fn wrap_connector<H>(self, conn: H) -> HttpsConnector<H>

This wraps an arbitrary low-level connector into an HttpsConnector

source§

impl ConnectorBuilder<WantsProtocols3>

source

pub fn build(self) -> HttpsConnector<HttpConnector>

This builds an HttpsConnector built on hyper’s default HttpConnector

source

pub fn wrap_connector<H>(self, conn: H) -> HttpsConnector<H>

This wraps an arbitrary low-level connector into an HttpsConnector

Trait Implementations§

source§

impl Default for ConnectorBuilder<WantsTlsConfig>

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<State> Freeze for ConnectorBuilder<State>
where State: Freeze,

§

impl<State> RefUnwindSafe for ConnectorBuilder<State>
where State: RefUnwindSafe,

§

impl<State> Send for ConnectorBuilder<State>
where State: Send,

§

impl<State> Sync for ConnectorBuilder<State>
where State: Sync,

§

impl<State> Unpin for ConnectorBuilder<State>
where State: Unpin,

§

impl<State> UnwindSafe for ConnectorBuilder<State>
where State: UnwindSafe,

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> 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, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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