pub struct ClientResponse { /* private fields */ }Expand description
An HTTP client response.
Implementations§
Source§impl ClientResponse
impl ClientResponse
Sourcepub fn status(&self) -> StatusCode
pub fn status(&self) -> StatusCode
Returns the response status.
Sourcepub fn header<N: AsName>(&self, name: N) -> Option<&HeaderValue>
pub fn header<N: AsName>(&self, name: N) -> Option<&HeaderValue>
Returns the first header value associated with name.
Sourcepub fn headers_mut(&mut self) -> &mut HeaderMap
pub fn headers_mut(&mut self) -> &mut HeaderMap
Returns mutable access to the response headers.
Sourcepub fn set_payload(&self, payload: Payload)
pub fn set_payload(&self, payload: Payload)
Replaces the response payload.
Any unread previous payload is dropped.
Sourcepub fn take_payload(&self) -> Payload
pub fn take_payload(&self) -> Payload
Takes the response payload.
Subsequent calls return an empty payload.
Sourcepub fn extensions(&self) -> Ref<'_, Extensions>
pub fn extensions(&self) -> Ref<'_, Extensions>
Returns the response extensions.
Sourcepub fn extensions_mut(&self) -> RefMut<'_, Extensions>
pub fn extensions_mut(&self) -> RefMut<'_, Extensions>
Returns mutable access to the response extensions.
Source§impl ClientResponse
impl ClientResponse
Sourcepub fn body(&self) -> MessageBody ⓘ
pub fn body(&self) -> MessageBody ⓘ
Returns a future that buffers the response body.
Sourcepub fn json<T: DeserializeOwned>(&self) -> JsonBody<T> ⓘ
pub fn json<T: DeserializeOwned>(&self) -> JsonBody<T> ⓘ
Returns a future that buffers and deserializes a JSON response body.
The future returns an error when:
- the content type is not JSON;
- the body exceeds the configured response payload limit; or
- reading or deserializing the body fails.
Trait Implementations§
Source§impl Debug for ClientResponse
impl Debug for ClientResponse
Source§impl From<ServiceResponse> for ClientResponse
impl From<ServiceResponse> for ClientResponse
Source§fn from(res: ServiceResponse) -> Self
fn from(res: ServiceResponse) -> Self
Converts to this type from the input type.
Source§impl HttpMessage for ClientResponse
impl HttpMessage for ClientResponse
Parses cookies from the response Set-Cookie headers.
Source§fn message_headers(&self) -> &HeaderMap
fn message_headers(&self) -> &HeaderMap
Returns the message headers.
Source§fn message_extensions(&self) -> Ref<'_, Extensions>
fn message_extensions(&self) -> Ref<'_, Extensions>
Returns the message extensions.
Source§fn message_extensions_mut(&self) -> RefMut<'_, Extensions>
fn message_extensions_mut(&self) -> RefMut<'_, Extensions>
Returns mutable access to the message extensions.
Source§fn content_type(&self) -> &str
fn content_type(&self) -> &str
Returns the media type from the
Content-Type header. Read moreSource§fn encoding(&self) -> Result<&'static Encoding, ContentTypeError>
fn encoding(&self) -> Result<&'static Encoding, ContentTypeError>
Returns the character encoding declared by
Content-Type. Read moreSource§fn mime_type(&self) -> Result<Option<Mime>, ContentTypeError>
fn mime_type(&self) -> Result<Option<Mime>, ContentTypeError>
Parses the
Content-Type header as a MIME type. Read moreReturns the first request cookie with the given name.
Source§impl Stream for ClientResponse
impl Stream for ClientResponse
Auto Trait Implementations§
impl !Freeze for ClientResponse
impl !RefUnwindSafe for ClientResponse
impl !Send for ClientResponse
impl !Sync for ClientResponse
impl !UnwindSafe for ClientResponse
impl Unpin for ClientResponse
impl UnsafeUnpin for ClientResponse
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