pub struct TestResponse { /* private fields */ }
Available on crate feature
__private
only.Implementations§
Methods from Deref<Target = Response>§
Sourcepub fn status(&self) -> StatusCode
pub fn status(&self) -> StatusCode
Get the StatusCode
of this Response
.
Sourcepub fn content_length(&self) -> Option<u64>
pub fn content_length(&self) -> Option<u64>
Get the content-length of this response, if known.
Reasons it may not be known:
- The server didn’t send a
content-length
header. - The response is compressed and automatically decoded (thus changing the actual decoded length).
Sourcepub fn remote_addr(&self) -> Option<SocketAddr>
pub fn remote_addr(&self) -> Option<SocketAddr>
Get the remote address used to get this Response
.
Sourcepub fn extensions(&self) -> &Extensions
pub fn extensions(&self) -> &Extensions
Returns a reference to the associated extensions.
Sourcepub fn error_for_status_ref(&self) -> Result<&Response, Error>
pub fn error_for_status_ref(&self) -> Result<&Response, Error>
Turn a reference to a response into an error if the server returned an error.
§Example
fn on_response(res: &Response) {
match res.error_for_status_ref() {
Ok(_res) => (),
Err(err) => {
// asserting a 400 as an example
// it could be any status between 400...599
assert_eq!(
err.status(),
Some(reqwest::StatusCode::BAD_REQUEST)
);
}
}
}
Trait Implementations§
Source§impl Debug for TestResponse
impl Debug for TestResponse
Auto Trait Implementations§
impl Freeze for TestResponse
impl !RefUnwindSafe for TestResponse
impl Send for TestResponse
impl Sync for TestResponse
impl Unpin for TestResponse
impl !UnwindSafe for TestResponse
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