Struct gloo::net::http::Request

source ·
pub struct Request(_);
Available on crate features net and 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) -> impl Future<Output = Result<FormData, Error>>

Reads the request to completion, returning it as FormData.

source

pub async fn json<T>(&self) -> impl Future<Output = Result<T, Error>>where T: DeserializeOwned,

Available on crate feature json only.

Reads the request to completion, parsing it as JSON.

source

pub async fn text(&self) -> impl Future<Output = Result<String, Error>>

Reads the reqeust as a String.

source

pub async fn binary( &self ) -> impl Future<Output = Result<Vec<u8, Global>, 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) -> impl Future<Output = Result<Response, Error>>

Executes the request.

Trait Implementations§

source§

impl Debug for Request

source§

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

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

impl From<Request> for Request

source§

fn from(raw: Request) -> Request

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<Request, <Request as TryFrom<RequestBuilder>>::Error>

Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere 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 Twhere 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.