pub struct Response { /* private fields */ }
http
only.Expand description
The Request
’s response
Implementations
sourceimpl Response
impl Response
sourcepub fn from_raw(raw: Response) -> Self
pub fn from_raw(raw: Response) -> Self
Build a Response from web_sys::Response.
sourcepub fn type_(&self) -> ResponseType
pub fn type_(&self) -> ResponseType
The type read-only property of the Response interface contains the type of the response.
It can be one of the following:
- basic: Normal, same origin response, with all headers exposed except “Set-Cookie” and “Set-Cookie2″.
- cors: Response was received from a valid cross-origin request. Certain headers and the body may be accessed.
- error: Network error. No useful information describing the error is available. The Response’s status is 0, headers are empty and immutable. This is the type for a Response obtained from Response.error().
- opaque: Response for “no-cors” request to cross-origin resource. Severely restricted.
- opaqueredirect: The fetch request was made with redirect: “manual”. The Response’s status is 0, headers are empty, body is null and trailer is empty.
sourcepub fn url(&self) -> String
pub fn url(&self) -> String
The URL of the response.
The returned value will be the final URL obtained after any redirects.
sourcepub fn redirected(&self) -> bool
pub fn redirected(&self) -> bool
Whether or not this response is the result of a request you made which was redirected.
sourcepub fn status(&self) -> u16
pub fn status(&self) -> u16
the HTTP status code of the response.
sourcepub fn ok(&self) -> bool
pub fn ok(&self) -> bool
Whether the HTTP status code
was a success code (in the range 200 - 299
).
sourcepub fn status_text(&self) -> String
pub fn status_text(&self) -> String
The status message corresponding to the
HTTP status code from
Response::status
.
For example, this would be ‘OK’ for a status code 200, ‘Continue’ for 100, or ‘Not Found’ for 404.
sourcepub fn body_used(&self) -> bool
pub fn body_used(&self) -> bool
Has the response body been consumed?
If true, then any future attempts to consume the body will error.
sourcepub fn body(&self) -> Option<ReadableStream>
pub fn body(&self) -> Option<ReadableStream>
Gets the body.
sourcepub async fn form_data(&self) -> Result<FormData, Error>
pub async fn form_data(&self) -> Result<FormData, Error>
Reads the response to completion, returning it as FormData
.
sourcepub async fn json<T: DeserializeOwned>(&self) -> Result<T, Error>
This is supported on crate feature json
only.
pub async fn json<T: DeserializeOwned>(&self) -> Result<T, Error>
json
only.Reads the response to completion, parsing it as JSON.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Response
impl !Send for Response
impl !Sync for Response
impl Unpin for Response
impl UnwindSafe for Response
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more