Struct gloo_net::http::Request

source ·
pub struct Request(/* private fields */);
Available on crate feature http only.
Expand description

The Request sent to the server

Implementations§

source§

impl Request

source

pub fn get(url: &str) -> RequestBuilder

Creates a new GET Request with url.

source

pub fn post(url: &str) -> RequestBuilder

Creates a new POST Request with url.

source

pub fn put(url: &str) -> RequestBuilder

Creates a new PUT Request with url.

source

pub fn delete(url: &str) -> RequestBuilder

Creates a new DELETE Request with url.

source

pub fn patch(url: &str) -> RequestBuilder

Creates a new PATCH Request with url.

source

pub fn url(&self) -> String

The URL of the request.

source

pub fn headers(&self) -> Headers

Gets the headers.

source

pub fn body_used(&self) -> bool

Has the request body been consumed?

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

source

pub fn body(&self) -> Option<ReadableStream>

Gets the body.

source

pub async fn form_data(&self) -> Result<FormData, Error>

Reads the request to completion, returning it as FormData.

source

pub async fn json<T: DeserializeOwned>(&self) -> Result<T, Error>

Available on crate feature json only.

Reads the request to completion, parsing it as JSON.

source

pub async fn text(&self) -> Result<String, Error>

Reads the reqeust as a String.

source

pub async fn binary(&self) -> Result<Vec<u8>, Error>

Gets the binary request

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

source

pub fn mode(&self) -> RequestMode

Return the read only mode for the request

source

pub fn method(&self) -> Method

Return the parsed method for the request

source

pub async fn send(self) -> Result<Response, Error>

Executes the request.

Trait Implementations§

source§

impl Debug for Request

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<Request> for Request

source§

fn from(raw: Request) -> Self

Converts to this type from the input type.
source§

impl From<Request> for Request

source§

fn from(val: Request) -> Self

Converts to this type from the input type.
source§

impl TryFrom<RequestBuilder> for Request

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(value: RequestBuilder) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.