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>
impl ConnectorBuilder<WantsTlsConfig>
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new ConnectorBuilder
Sourcepub fn with_tls_config(
self,
config: ClientConfig,
) -> ConnectorBuilder<WantsSchemes>
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.
Sourcepub fn with_native_roots(self) -> ConnectorBuilder<WantsSchemes>
pub fn with_native_roots(self) -> ConnectorBuilder<WantsSchemes>
Shorthand for using rustls’ safe defaults and native roots
Source§impl ConnectorBuilder<WantsSchemes>
impl ConnectorBuilder<WantsSchemes>
Sourcepub fn https_only(self) -> ConnectorBuilder<WantsProtocols1>
pub fn https_only(self) -> ConnectorBuilder<WantsProtocols1>
Enforce the use of HTTPS when connecting
Only URLs using the HTTPS scheme will be connectable.
Sourcepub fn https_or_http(self) -> ConnectorBuilder<WantsProtocols1>
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>
impl ConnectorBuilder<WantsProtocols1>
Sourcepub fn enable_http1(self) -> ConnectorBuilder<WantsProtocols2>
pub fn enable_http1(self) -> ConnectorBuilder<WantsProtocols2>
Enable HTTP1
This needs to be called explicitly, no protocol is enabled by default
Source§impl ConnectorBuilder<WantsProtocols2>
impl ConnectorBuilder<WantsProtocols2>
Sourcepub fn build(self) -> HttpsConnector<HttpConnector>
pub fn build(self) -> HttpsConnector<HttpConnector>
This builds an HttpsConnector
built on hyper’s default HttpConnector
Sourcepub fn wrap_connector<H>(self, conn: H) -> HttpsConnector<H>
pub fn wrap_connector<H>(self, conn: H) -> HttpsConnector<H>
This wraps an arbitrary low-level connector into an HttpsConnector