pub struct BoundedHttpClient { /* private fields */ }Expand description
Wraps any HttpClient so the port’s bounds hold on every runtime:
the deadline is enforced through the Clock port (the
only timer core is allowed to use), and the response is refused — by
declared length before anything else, then by actual size — when it
exceeds the HttpPolicy cap.
This is defence in depth, not the only defence: the native adapter
also enforces the cap while streaming (before the oversized body is
ever buffered) and the Workers adapter checks the declared length
before calling bytes(). Runtimes wire every ports.http through
this wrapper.
Implementations§
Trait Implementations§
Source§impl HttpClient for BoundedHttpClient
impl HttpClient for BoundedHttpClient
Source§fn send<'life0, 'async_trait>(
&'life0 self,
request: Request<Bytes>,
) -> Pin<Box<dyn Future<Output = Result<Response<Bytes>, HttpError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn send<'life0, 'async_trait>(
&'life0 self,
request: Request<Bytes>,
) -> Pin<Box<dyn Future<Output = Result<Response<Bytes>, HttpError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Sends
request and returns the fully-buffered response under the
bounds this port carries: the body is at most
MAX_RESPONSE_BYTES unless an HttpPolicy tightens it, the
exchange is bounded by that policy’s deadline
(enforced through BoundedHttpClient on runtimes that wrap),
the destination is vetted where real sockets are opened, and a
runtime that keeps a concurrency budget holds one for the send.Auto Trait Implementations§
impl !RefUnwindSafe for BoundedHttpClient
impl !UnwindSafe for BoundedHttpClient
impl Freeze for BoundedHttpClient
impl Send for BoundedHttpClient
impl Sync for BoundedHttpClient
impl Unpin for BoundedHttpClient
impl UnsafeUnpin for BoundedHttpClient
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