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

Provide methods in Request class to set connection and read timeouts #29

Closed
jamietsao opened this issue Nov 3, 2010 · 7 comments
Closed
Labels

Comments

@jamietsao
Copy link
Contributor

Can you add public methods to the Request class so that connection and read timeouts can be set on the contained HttpURLConnection object? I see that you have a setTimeout() method but if I'm not mistaken, it can't be used properly as is. The "timeout" variable is acted upon in the constructor so by the time the setTimeout() method is called, it's already too late.

Effectively, I would like wrapper methods around HttpURLConnection's setConnectTimeout() and setReadTimeout() methods.

BTW - awesome library!

@fernandezpablo85
Copy link
Collaborator

Now that you mention it... yeah, I don't know what happened when I was coding that... :P

Is it absolutely necessary to support both timeouts? wouldn't the connect timeout just do?

Thanks!

@jamietsao
Copy link
Contributor Author

I need the read timeout because I'm processing a persistent stream of data via getInputStream() for a long duration. In case the connection is dropped, the read timeout is necessary so that an IOException is thrown. The connection timeout is only useful for the initial connection.

@fernandezpablo85
Copy link
Collaborator

Ok.

planned for 1.0.8

@jamietsao
Copy link
Contributor Author

Great thanks! Let me know if you want me to make this change so you can pull/merge.

@fernandezpablo85
Copy link
Collaborator

Yes that would be awesome.

Just note the 2 spaces for indent and the K&R braces.

Thanks!

@jamietsao
Copy link
Contributor Author

I just sent you a pull request for this. Let me know when 1.0.8 is available!

@fernandezpablo85
Copy link
Collaborator

Merged, I just changed the signature to this:

setConnectTimeout(int duration, TimeUnit unit)

so you can set the timeout both in seconds and millis.

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

No branches or pull requests

2 participants