pub struct HttpSender { /* private fields */ }
Implementations§
Source§impl HttpSender
impl HttpSender
Sourcepub fn new<T: AsRef<str>>(url: T) -> Self
pub fn new<T: AsRef<str>>(url: T) -> Self
Creates a new HttpSender
instance with a default set of trusted root CAs.
By default, the client trusts the Mozilla root certificates provided by the
webpki_roots
crate to validate server certificates.
To add a custom Certificate Authority (CA), use [add_root_ca()
] before sending the request.
Sourcepub fn add_root_ca<T: AsRef<Path>>(self, root_ca_path: T) -> Self
pub fn add_root_ca<T: AsRef<Path>>(self, root_ca_path: T) -> Self
Add a custom root certificate authority (CA) in PEM format for verifying TLS connections.
Sourcepub fn http1_only(self) -> Self
pub fn http1_only(self) -> Self
Force the use of HTTP/1.1.
Sourcepub fn http2_only(self) -> Self
pub fn http2_only(self) -> Self
Force the use of HTTP/2.
Sourcepub async fn send(
&self,
request: HttpRequest,
) -> Result<HttpResponse, Box<dyn Error + Send + Sync>>
pub async fn send( &self, request: HttpRequest, ) -> Result<HttpResponse, Box<dyn Error + Send + Sync>>
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.
Auto Trait Implementations§
impl Freeze for HttpSender
impl RefUnwindSafe for HttpSender
impl Send for HttpSender
impl Sync for HttpSender
impl Unpin for HttpSender
impl UnwindSafe for HttpSender
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
Mutably borrows from an owned value. Read more