Skip to main content

HttpRequest

Struct HttpRequest 

Source
pub struct HttpRequest {
    pub method: Method,
    pub url: String,
    pub headers: HashMap<String, String>,
    pub body: Body,
    pub config: RequestConfig,
    /* private fields */
}
Expand description

HTTP request data and execution state.

Holds everything needed to issue one outgoing request: method, URL, headers (single-value HashMap<String, String> — see hyperlane-standards §8.1), body, and per-request config (timeout, redirect policy, proxy, decode, etc.).

HttpRequest is constructed either via crate::RequestBuilder or directly from its public fields, then sent via HttpRequest::send (sync) or HttpRequest::send_async.

Fields§

§method: Method

HTTP method (Method::Get / Method::Post / …).

§url: String

Target URL (string form, parsed on send).

§headers: HashMap<String, String>

Request headers (single-value).

§body: Body

Request body.

§config: RequestConfig

Per-request config: timeout, redirects, proxy, decode, etc.

Implementations§

Source§

impl HttpRequest

Source

pub fn send(&mut self) -> RequestResult

Send the HTTP request synchronously, returning the parsed response.

Source

pub async fn send_async(&mut self) -> RequestResult

Send the HTTP request asynchronously, returning the parsed response.

Source§

impl HttpRequest

Source

pub fn get(url: impl Into<String>) -> Self

Create a GET request for url.

Source

pub fn post(url: impl Into<String>) -> Self

Create a POST request for url.

Source

pub fn set_method(&mut self, method: Method) -> &mut Self

Builder-style: set method.

Source

pub fn set_url(&mut self, url: impl Into<String>) -> &mut Self

Builder-style: set URL.

Source

pub fn set_header<K: AsRef<str>, V: AsRef<str>>( &mut self, key: K, value: V, ) -> &mut Self

Builder-style: set a single header (case-insensitive on read; the last value wins for repeated keys).

Source

pub fn remove_header<K: AsRef<str>>(&mut self, key: K) -> &mut Self

Remove a header by key.

Source

pub fn clear_headers(&mut self) -> &mut Self

Clear all headers.

Source

pub fn set_body(&mut self, body: Body) -> &mut Self

Set body (raw bytes).

Source

pub fn set_config(&mut self, config: RequestConfig) -> &mut Self

Set a single config field by mutating the embedded RequestConfig.

Trait Implementations§

Source§

impl Clone for HttpRequest

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for HttpRequest

Source§

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

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

impl Default for HttpRequest

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> AnySend for T
where T: Any + Send,

Source§

impl<T> AnySendClone for T
where T: Any + Send + Clone,

Source§

impl<T> AnySendSync for T
where T: Any + Send + Sync,

Source§

impl<T> AnySendSyncClone for T
where T: Any + Send + Sync + Clone,

Source§

impl<T> AnySync for T
where T: Any + Sync,

Source§

impl<T> AnySyncClone for T
where T: Any + Sync + Clone,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.