If the initial request is rate limited or a server error occurred then the form is lost for the next iteration.
|
Box::new(futures::future::loop_fn(Arc::clone(rl), move |ratelimit| { |
|
let req_url = format!("{}{}", base, &endpt.url); |
|
let route = Bucket::make_route(endpt.method.clone(), req_url.clone()); |
|
let mut req = http.request(endpt.method.clone(), &req_url) |
|
.query(&endpt.query) |
|
.json(&endpt.json); |
|
if endpt.multipart.is_some() { |
|
let form = endpt.multipart.take().unwrap(); |
|
req = req.multipart(form); |
|
}; |
|
let limiter = Arc::clone(&ratelimit); |
|
let limiter_2 = Arc::clone(&limiter); |
|
ratelimit.lock().enqueue(route.clone()) |
|
.and_then(|_| req.send().from_err()) |
|
.and_then(move |resp| limiter.lock().handle_resp(route, resp)) |
|
.map(move |status| match status { |
|
ResponseStatus::Success(resp) => Loop::Break(resp), |
|
ResponseStatus::Ratelimited | ResponseStatus::ServerError => Loop::Continue(limiter_2) |
|
}) |
|
}).and_then(|mut resp| resp.json().from_err())) |
If the initial request is rate limited or a server error occurred then the form is lost for the next iteration.
spectacles-rs/rest/src/lib.rs
Lines 257 to 276 in 3b9d4a7