Skip to content
This repository has been archived by the owner on Aug 4, 2019. It is now read-only.

Multipart is lost if the initial request is rate limited or a server error occurred. #5

Open
nickelc opened this issue Jul 15, 2019 · 0 comments

Comments

@nickelc
Copy link

nickelc commented Jul 15, 2019

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()))

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant