Skip to main content

RequestBuilder

Struct RequestBuilder 

Source
pub struct RequestBuilder<'a> { /* private fields */ }
Expand description

Builder for an HTTP request.

Implementations§

Source§

impl<'a> RequestBuilder<'a>

Source

pub fn header(self, name: &str, value: &str) -> Self

Add a header to the request.

Source

pub fn body(self, body: impl Into<Body>) -> Self

Set the request body.

Source

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

Send the request and return the response.

Source

pub async fn send_streaming(self) -> Result<StreamingResponse<'a>, HttpError>

Send the request and return a streaming response.

Returns as soon as headers are received. Body chunks are yielded incrementally via StreamingResponse::next_chunk().

Note: streaming responses do not automatically decompress the body. If the server sends a compressed response, chunks will contain raw compressed bytes. Buffer and decompress manually if needed.

Auto Trait Implementations§

§

impl<'a> !Freeze for RequestBuilder<'a>

§

impl<'a> !RefUnwindSafe for RequestBuilder<'a>

§

impl<'a> !UnwindSafe for RequestBuilder<'a>

§

impl<'a> Send for RequestBuilder<'a>

§

impl<'a> Sync for RequestBuilder<'a>

§

impl<'a> Unpin for RequestBuilder<'a>

§

impl<'a> UnsafeUnpin for RequestBuilder<'a>

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>,

Source§

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>,

Source§

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.