pub struct FakeHttpClient { /* private fields */ }Expand description
In-memory HttpClient fake that scripts responses per URL.
Requests to URLs without a scripted result fail with
WebFetchError::RequestFailed.
Implementations§
Source§impl FakeHttpClient
impl FakeHttpClient
Sourcepub fn with_response(self, url: &str, response: HttpResponse) -> Self
pub fn with_response(self, url: &str, response: HttpResponse) -> Self
Scripts a full response for url, including redirects via final_url.
Sourcepub fn with_html(self, url: &str, html: &str) -> Self
pub fn with_html(self, url: &str, html: &str) -> Self
Scripts a 200 response whose body is html and whose final_url is url.
Sourcepub fn with_timeout(self, url: &str, timeout_ms: u64) -> Self
pub fn with_timeout(self, url: &str, timeout_ms: u64) -> Self
Scripts a WebFetchError::Timeout carrying timeout_ms for url.
Sourcepub fn with_request_failed(self, url: &str, message: &str) -> Self
pub fn with_request_failed(self, url: &str, message: &str) -> Self
Scripts a WebFetchError::RequestFailed carrying message for url.
Trait Implementations§
Source§impl Clone for FakeHttpClient
impl Clone for FakeHttpClient
Source§impl Debug for FakeHttpClient
impl Debug for FakeHttpClient
Source§impl Default for FakeHttpClient
impl Default for FakeHttpClient
Source§impl HttpClient for FakeHttpClient
impl HttpClient for FakeHttpClient
fn fetch<'a>( &'a self, url: &'a str, _timeout: Duration, ) -> BoxFuture<'a, Result<HttpResponse, WebFetchError>>
Auto Trait Implementations§
impl Freeze for FakeHttpClient
impl RefUnwindSafe for FakeHttpClient
impl Send for FakeHttpClient
impl Sync for FakeHttpClient
impl Unpin for FakeHttpClient
impl UnsafeUnpin for FakeHttpClient
impl UnwindSafe for FakeHttpClient
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.