pub struct ReqwestClient { /* private fields */ }Available on crate feature
did-web and crate feature reqwest and (crate features did-jwk or did-key or did-web) only.Expand description
An HttpClient over reqwest hardened for fetching DID documents from the public web.
ReqwestClient::new builds a client that:
- speaks HTTPS only, with the platform’s root certificates and
rustls; - follows no redirect, so a document is fetched from the URL its DID maps to and nowhere else;
- resolves host names itself and refuses loopback, private, link-local and other non-public addresses, so a DID cannot point the resolver at internal services;
- stops reading a body over
DEFAULT_MAX_BODYbytes; - times out after
DEFAULT_TIMEOUT.
ReqwestClient::from_client wraps a client the application configured itself, keeping
only the HTTPS-only rule, the refusal of non-public IP literals and the body limit; the
other protections are then the application’s.
Implementations§
Source§impl ReqwestClient
impl ReqwestClient
Sourcepub const DEFAULT_MAX_BODY: usize
pub const DEFAULT_MAX_BODY: usize
The largest body new reads: 1 MiB, far above any DID document.
Sourcepub const DEFAULT_TIMEOUT: Duration
pub const DEFAULT_TIMEOUT: Duration
The request timeout of new.
Sourcepub const fn from_client(client: Client) -> Self
pub const fn from_client(client: Client) -> Self
A client over client as the application configured it, still HTTPS-only, refusing
non-public IP literals, and reading at most DEFAULT_MAX_BODY
bytes of body.
Sourcepub const fn with_max_body(self, max_body: usize) -> Self
pub const fn with_max_body(self, max_body: usize) -> Self
This client reading at most max_body bytes of body.
Trait Implementations§
Source§impl Clone for ReqwestClient
impl Clone for ReqwestClient
Source§impl Debug for ReqwestClient
impl Debug for ReqwestClient
Source§impl HttpClient for ReqwestClient
impl HttpClient for ReqwestClient
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,
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. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for ReqwestClient
impl !UnwindSafe for ReqwestClient
impl Freeze for ReqwestClient
impl Send for ReqwestClient
impl Sync for ReqwestClient
impl Unpin for ReqwestClient
impl UnsafeUnpin for ReqwestClient
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