pub struct Response { /* private fields */ }Expand description
HTTP response with explicit decompression.
Implementations§
Source§impl Response
impl Response
pub fn new( status: u16, headers: Headers, body: Bytes, http_version: String, ) -> Self
Sourcepub fn with_url(self, url: Url) -> Self
pub fn with_url(self, url: Url) -> Self
Set the effective URL (the URL that was actually requested). This is used by the redirect engine to track the current URL.
pub fn http_version(&self) -> &str
pub fn status(&self) -> StatusCode
pub fn status_code(&self) -> u16
pub fn headers(&self) -> &Headers
pub fn url(&self) -> Option<&Url>
pub fn body(&self) -> &Bytes
pub fn bytes_raw(&self) -> Bytes
pub fn into_body(self) -> Bytes
pub fn bytes(&self) -> Result<Bytes>
pub fn is_success(&self) -> bool
pub fn is_redirect(&self) -> bool
pub fn redirect_url(&self) -> Option<&str>
pub fn get_header(&self, name: &str) -> Option<&str>
pub fn get_headers(&self, name: &str) -> Vec<&str>
pub fn content_type(&self) -> Option<&str>
pub fn content_encoding(&self) -> Option<&str>
Sourcepub fn decoded_body(&self) -> Result<Bytes>
pub fn decoded_body(&self) -> Result<Bytes>
Decode body based on Content-Encoding (gzip, deflate, br, zstd). Supports chained encodings (e.g., “gzip, deflate”) by applying decodings in reverse order.
pub fn text(&self) -> Result<String>
pub fn json<T: DeserializeOwned>(&self) -> Result<T>
pub fn error_for_status(self) -> Result<Self>
pub fn error_for_status_ref(&self) -> Result<&Self>
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Response
impl RefUnwindSafe for Response
impl Send for Response
impl Sync for Response
impl Unpin for Response
impl UnsafeUnpin for Response
impl UnwindSafe for Response
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
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 more