pub struct Request { /* private fields */ }Expand description
A request being built; send it with Request::send.
Implementations§
Source§impl Request
impl Request
Sourcepub fn header(self, name: &str, value: impl Into<String>) -> Self
pub fn header(self, name: &str, value: impl Into<String>) -> Self
Adds a header (repeatable: a name may be sent more than once).
Sourcepub fn basic_auth(self, user: &str, password: &str) -> Self
pub fn basic_auth(self, user: &str, password: &str) -> Self
Authorization: Basic ….
Sourcepub fn form(self, body: &impl Serialize) -> Self
pub fn form(self, body: &impl Serialize) -> Self
A form body (application/x-www-form-urlencoded).
Sourcepub fn body(self, content_type: &str, body: impl Into<Vec<u8>>) -> Self
pub fn body(self, content_type: &str, body: impl Into<Vec<u8>>) -> Self
A raw body with its content type.
Sourcepub fn timeout(self, timeout: Duration) -> Self
pub fn timeout(self, timeout: Duration) -> Self
How long one attempt may take (30 s by default).
Sourcepub fn retry(self, times: u32, delay: Duration) -> Self
pub fn retry(self, times: u32, delay: Duration) -> Self
Tries again up to times more times after a connection error, a
timeout, a 429 or a 5xx, waiting delay, then twice that, and so on.
Sourcepub async fn send(self) -> Result<Response>
pub async fn send(self) -> Result<Response>
Sends the request (with its retries) and reads the whole response.
Any status is a response; see Response::error_for_status.
Auto Trait Implementations§
impl Freeze for Request
impl RefUnwindSafe for Request
impl Send for Request
impl Sync for Request
impl Unpin for Request
impl UnsafeUnpin for Request
impl UnwindSafe for Request
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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