pub struct HttpRequest {
pub method: HttpMethod,
pub url: Url,
pub headers: HashMap<String, String>,
pub body: Option<Bytes>,
pub timeout: Option<Duration>,
pub follow_redirects: bool,
pub max_redirects: u32,
pub user_agent: Option<String>,
}
Expand description
HTTP request builder
Fields§
§method: HttpMethod
§url: Url
§headers: HashMap<String, String>
§body: Option<Bytes>
§timeout: Option<Duration>
§follow_redirects: bool
§max_redirects: u32
§user_agent: Option<String>
Implementations§
Source§impl HttpRequest
impl HttpRequest
pub fn new(method: HttpMethod, url: Url) -> Self
pub fn get(url: Url) -> Self
pub fn post(url: Url) -> Self
pub fn header(self, key: String, value: String) -> Self
pub fn body(self, body: impl Into<Bytes>) -> Self
pub fn json<T: Serialize>(self, data: &T) -> Result<Self, Error>
pub fn form(self, data: &HashMap<String, String>) -> Self
pub fn timeout(self, duration: Duration) -> Self
pub fn user_agent(self, ua: String) -> Self
pub fn no_redirects(self) -> Self
Trait Implementations§
Source§impl Clone for HttpRequest
impl Clone for HttpRequest
Source§fn clone(&self) -> HttpRequest
fn clone(&self) -> HttpRequest
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl !Freeze for HttpRequest
impl RefUnwindSafe for HttpRequest
impl Send for HttpRequest
impl Sync for HttpRequest
impl Unpin for HttpRequest
impl UnwindSafe for HttpRequest
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more