Struct gloo_net::http::Response

source ·
pub struct Response { /* private fields */ }
Available on crate feature http only.
Expand description

The Request’s response

Implementations§

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.

The URL of the response.

The returned value will be the final URL obtained after any redirects.

Whether or not this response is the result of a request you made which was redirected.

the HTTP status code of the response.

Whether the HTTP status code was a success code (in the range 200 - 299).

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.

Gets the headers.

Has the response body been consumed?

If true, then any future attempts to consume the body will error.

Gets the body.

Gets the raw Response object.

Reads the response to completion, returning it as FormData.

Available on crate feature json only.

Reads the response to completion, parsing it as JSON.

Reads the response as a String.

Gets the binary response

This works by obtaining the response as an ArrayBuffer, creating a Uint8Array from it and then converting it to Vec<u8>

Trait Implementations§

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.