pub struct HttpSender { /* private fields */ }
Implementations§
Source§impl HttpSender
impl HttpSender
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new HttpSender
instance with a default set of trusted root CAs.
This initializes the internal RootCertStore
with the Mozilla-recommended TLS_SERVER_ROOTS
for use in TLS client connections.
To use a custom root certificate authority (CA), call the [tls_root_ca()
] method
before sending the request. This will override the default trust store.
Sourcepub fn root_ca<T: AsRef<Path>>(self, root_ca_path: T) -> Self
pub fn root_ca<T: AsRef<Path>>(self, root_ca_path: T) -> Self
Sets a custom root certificate authority (CA) in PEM format for verifying TLS connections.
This overrides the default Mozilla trust store used for HTTPS connections.
Sourcepub async fn send<T: AsRef<str>>(
&self,
url: T,
request: HttpRequest,
) -> ResultDyn<HttpResponse>
pub async fn send<T: AsRef<str>>( &self, url: T, request: HttpRequest, ) -> ResultDyn<HttpResponse>
Sends an HTTP request to the server, automatically selecting the appropriate protocol and transport.
If the URL scheme is "http"
, HTTP/1.1 will be used for the request.
If the URL scheme is "https"
, a secure TLS connection is established and ALPN is used to determine whether to use HTTP/2 or HTTP/1.1 for the request.
By default, the client trusts the Mozilla root certificates provided by the
webpki_roots
crate to validate server certificates.
To override the default root certificate store and use a custom Certificate Authority (CA),
call [tls_root_ca()
] before sending the request.