Skip to content
This repository was 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

Description

@nickelc

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions