pub struct PendingRequest { /* private fields */ }Expand description
A request being built.
Implementations§
Source§impl PendingRequest
impl PendingRequest
Sourcepub fn accept_json(self) -> Self
pub fn accept_json(self) -> Self
Accept: application/json.
Sourcepub fn json<T: Serialize>(self, value: &T) -> Result<Self>
pub fn json<T: Serialize>(self, value: &T) -> Result<Self>
Send value as a JSON body.
§Errors
If it will not serialise — reported here rather than at send, so the
failure is next to the value that caused it.
Sourcepub fn timeout(self, timeout: Duration) -> Self
pub fn timeout(self, timeout: Duration) -> Self
How long to wait before giving up.
Thirty seconds by default. A request with no timeout is one that can hold a worker forever when the other end stops answering without closing, which is the failure mode that takes a queue down.
Sourcepub fn without_timeout(self) -> Self
pub fn without_timeout(self) -> Self
Wait indefinitely.
Almost never right; see timeout.
Sourcepub fn retry(self, attempts: u32, backoff: Backoff) -> Self
pub fn retry(self, attempts: u32, backoff: Backoff) -> Self
Try up to attempts times, waiting per backoff.
Only failures worth repeating are repeated — see
is_retryable, and read it before
assuming a 422 will be retried, because it will not.
Sourcepub fn through(self, transport: Arc<dyn Transport>) -> Self
pub fn through(self, transport: Arc<dyn Transport>) -> Self
Send through this transport rather than the installed one.
For a caller holding its own client — a different proxy, a pinned certificate — without changing what the rest of the process does.
Sourcepub async fn send(self) -> Result<HttpResponse>
pub async fn send(self) -> Result<HttpResponse>
Send it.
Returns Ok for any response that arrived, including a 500 — see
HttpResponse::error_for_status. Err means nothing came back at
all after every attempt.