Added methods to allow for setting the connect and read timeouts on the underlying HttpURLConnection

This commit is contained in:
Jamie Tsao committed 2010-11-04 15:23:19 -04:00
1 parent 9cb2af37c7
commit 3e7291eaee
1 file changed
+14 -6
+14 -6
View File
@@ -21,7 +21,6 @@ class Request
private Map<String, String> bodyParams; private Map<String, String> bodyParams;
private Map<String, String> headers; private Map<String, String> headers;
private String payload = null; private String payload = null;
private Integer timeout = null;
private HttpURLConnection connection; private HttpURLConnection connection;
/** /**
@@ -39,7 +38,6 @@ class Request
try try
{ {
connection = (HttpURLConnection) new URL(url).openConnection(); connection = (HttpURLConnection) new URL(url).openConnection();
if(timeout != null) connection.setConnectTimeout(timeout);
} catch (IOException ioe) } catch (IOException ioe)
{ {
throw new OAuthException("Could not open connection to: " + url, ioe); throw new OAuthException("Could not open connection to: " + url, ioe);
@@ -212,13 +210,23 @@ class Request
} }
/** /**
* Sets the connection timeout in milliseconds for the underlying {@link HttpURLConnection} * Sets the connect timeout in milliseconds for the underlying {@link HttpURLConnection}
* *
* @param timeout in milliseconds * @param connect timeout in milliseconds
*/ */
public void setTimeout(int timeout) public void setConnectTimeout(int timeout)
{ {
this.timeout = timeout; this.connection.setConnectTimeout(timeout);
}
/**
* Sets the read timeout in milliseconds for the underlying {@link HttpURLConnection}
*
* @param read timeout in milliseconds
*/
public void setReadTimeout(int timeout)
{
this.connection.setReadTimeout(timeout);
} }
/* /*