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

Implement request timeout by adding deadline to base stream #39

Closed
wants to merge 1 commit into from
Closed

Implement request timeout by adding deadline to base stream #39

wants to merge 1 commit into from

Conversation

adamreichold
Copy link
Contributor

No description provided.

src/streams.rs Outdated Show resolved Hide resolved
@sbstp
Copy link
Owner

sbstp commented Jan 8, 2020

Could you add a test for this too? I think you could use an end-to-end test in the tests directory. Create a TcpListener that accepts streams and writes a partial response only to the stream, i.e. by not terminating the request properly, then make an http request to that listener and verify if it timeouts.

I've been thinking about it however, and I thought of a case which might break because of this. Say you download a really large file that takes a long time to transfer. If the request timeout is short it would most probably be reached every time. That use case would probably be best served by a connect timeout and a read timeout. It might just be best to allow people to configure a connect timeout and a read timeout. The happy code already supports a timeout.

@adamreichold
Copy link
Contributor Author

I've been thinking about it however, and I thought of a case which might break because of this. Say you download a really large file that takes a long time to transfer. If the request timeout is short it would most probably be reached every time. That use case would probably be best served by a connect timeout and a read timeout. It might just be best to allow people to configure a connect timeout and a read timeout. The happy code already supports a timeout.

Personally, I am not a fan of this approach here at all due what I said before: I think this is pushing attohttpc into use cases for which it was not designed. Exposing the underlying connect and read timeouts only seems more reasonable to me.

@sbstp
Copy link
Owner

sbstp commented Jan 8, 2020

Yeah I think I agree. We should only go for a connect & read timeout. We should also set default values of like 30s for each, so that we don't hang programs. If the timeouts are too short for some use cases the defaults can just be bumped via the RequestBuilder.

@adamreichold
Copy link
Contributor Author

I'll extend #37 to support connect timeout, add the defaults and end-to-end tests. (Consider the 30s value, the current connect timeout in happy.rs is 10s, should I change this to 30s or should Request use a separate default?)

@sbstp
Copy link
Owner

sbstp commented Jan 8, 2020

I think we can move the default timeout value away from the happy module and also set it to 30s. I think 30s is a little bit more standard than 10s.

@adamreichold
Copy link
Contributor Author

Closing in favor of #37

@adamreichold adamreichold deleted the request-timeout branch January 8, 2020 19:54
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 this pull request may close these issues.

2 participants