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

Add read_timeout option #2237

Closed
seanmonstar opened this issue Apr 5, 2024 · 0 comments · Fixed by #2241
Closed

Add read_timeout option #2237

seanmonstar opened this issue Apr 5, 2024 · 0 comments · Fixed by #2241
Assignees

Comments

@seanmonstar
Copy link
Owner

The ClientBuilder::timeout() option describes a timeout for the entire request and response. Also considered a deadline. So, if you set the timeout to 30 seconds, if the full response hasn't finished after 30s, the streaming will error. However, many times that's not what is wanted. Many would like a timeout to detect a stalled download, but can't know ahead of time how big the download is.

Solution: add ClientBuilder::read_timeout(Duration), which is a recurring timeout for each read operation. Basically, if you set the read_timeout to 30s, it will wait up to 30s for the response headers. Then, each chunk of the body gets a new slice of 30 seconds.

Implementation wise, this can make use of the TimeoutBody type in tower-http, internally inside Response, if the timeout is set.

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

Successfully merging a pull request may close this issue.

1 participant