pub struct Response { /* private fields */ }Expand description
HTTP response wrapper providing convenience methods for body consumption.
Implementations§
Source§impl Response
impl Response
Sourcepub fn status(&self) -> StatusCode
pub fn status(&self) -> StatusCode
HTTP status code.
Sourcepub fn content_length(&self) -> Option<u64>
pub fn content_length(&self) -> Option<u64>
Content-Length header as u64 if present and valid.
Sourcepub async fn body_bytes(self) -> Result<Bytes, OxiHttpError>
pub async fn body_bytes(self) -> Result<Bytes, OxiHttpError>
Consume the body and return raw bytes, auto-decompressing if enabled.
Sourcepub async fn body_text(self) -> Result<String, OxiHttpError>
pub async fn body_text(self) -> Result<String, OxiHttpError>
Consume the body and return it as a UTF-8 string.
Sourcepub async fn body_json<T: DeserializeOwned>(self) -> Result<T, OxiHttpError>
pub async fn body_json<T: DeserializeOwned>(self) -> Result<T, OxiHttpError>
Consume the body and deserialize it as JSON.
Sourcepub fn error_for_status(self) -> Result<Self, OxiHttpError>
pub fn error_for_status(self) -> Result<Self, OxiHttpError>
Return an error if the response status is a client (4xx) or server (5xx) error.
Returns Ok(self) for success and redirect status codes.
Sourcepub fn content_type(&self) -> Option<&str>
pub fn content_type(&self) -> Option<&str>
Returns the Content-Type header value as a string, if present.
Parse all Set-Cookie response headers using oxihttp_core::Cookie::parse_set_cookie.
Returns an empty Vec when there are no Set-Cookie headers or none parse
successfully.
Sourcepub fn body_stream(self) -> BodyStream
pub fn body_stream(self) -> BodyStream
Consume the response and return the body as an async stream of chunks.
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