Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reqwest-retry: Retry from the last position via a Range request if connection fails in the middle of the body #36

Open
sdroege opened this issue Mar 15, 2022 · 1 comment
Labels
enhancement New feature or request reqwest-retry Issues related to the retry middleware

Comments

@sdroege
Copy link

sdroege commented Mar 15, 2022

Motivations

For use-cases where the whole body is received as a single, not too large blob, the current behaviour makes sense but for e.g. downloading media files it would make sense to also handle the case where the request succeeds but somewhere in the middle of the body there's a connection failure.

Solution

In that case a Range request to start at the last previously downloaded position could be performed on retry. This needs keeping track of the position and also of any Range header in the original requests.

@sdroege sdroege added the enhancement New feature or request label Mar 15, 2022
@conradludgate conradludgate added the reqwest-retry Issues related to the retry middleware label Aug 30, 2022
@conradludgate
Copy link
Collaborator

This is an interesting idea. I think this should be a separate middleware since it's quite a strong requirement - eg we would need to read the body which is something we currently don't do.

Criteria: If there's the Accept-Ranges: bytes and a Content-Length specified in the response, we can enable the range loop.

While the reqwest::Response object cannot have the body re-inserted, I believe we may be able to reconstruct it by using http::Response to pass back in the chain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request reqwest-retry Issues related to the retry middleware
Development

No branches or pull requests

2 participants