Skip to main content

HttpClient

Trait HttpClient 

Source
pub trait HttpClient: Send + Sync {
    // Required method
    fn get<'life0, 'life1, 'async_trait>(
        &'life0 self,
        url: &'life1 Url,
    ) -> Pin<Box<dyn Future<Output = Result<HttpResponse, HttpError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Available on crate feature did-web and (crate features did-jwk or did-key or did-web) only.
Expand description

What DidWeb needs from HTTP: a GET of a URL.

Implement it over the HTTP client of the application so did:web resolution shares its connection pool, proxy and TLS settings. The implementation decides the security policy: ReqwestClient is the one this crate ships.

Every URL a client is given comes from untrusted input (a DID, a credential’s status list reference), so an implementation must refuse what ReqwestClient refuses, or weigh the consequence: plain http, redirects, hosts that resolve to loopback, private, link-local or other non-public addresses, unbounded bodies and unbounded waits.

Required Methods§

Source

fn get<'life0, 'life1, 'async_trait>( &'life0 self, url: &'life1 Url, ) -> Pin<Box<dyn Future<Output = Result<HttpResponse, HttpError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Fetches url, returning the status and the body of the final response.

§Errors

Any failure to get a response: a refused URL, a network or TLS error, a timeout, a body over the client’s limit. An HTTP error status is a response, not an error.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T: HttpClient + ?Sized> HttpClient for &T

Source§

fn get<'life0, 'life1, 'async_trait>( &'life0 self, url: &'life1 Url, ) -> Pin<Box<dyn Future<Output = Result<HttpResponse, HttpError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

impl<T: HttpClient + ?Sized> HttpClient for Arc<T>

Source§

fn get<'life0, 'life1, 'async_trait>( &'life0 self, url: &'life1 Url, ) -> Pin<Box<dyn Future<Output = Result<HttpResponse, HttpError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

impl<T: HttpClient + ?Sized> HttpClient for Box<T>

Source§

fn get<'life0, 'life1, 'async_trait>( &'life0 self, url: &'life1 Url, ) -> Pin<Box<dyn Future<Output = Result<HttpResponse, HttpError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Implementors§