Skip to content

Commit 3e7291e

Browse files
committed
Added methods to allow for setting the connect and read timeouts on the underlying HttpURLConnection
1 parent 9cb2af3 commit 3e7291e

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

‎src/main/java/org/scribe/model/Request.java‎

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ class Request
2121
private Map<String, String> bodyParams;
2222
private Map<String, String> headers;
2323
private String payload = null;
24-
private Integer timeout = null;
2524
private HttpURLConnection connection;
2625

2726
/**
@@ -39,7 +38,6 @@ public Request(Verb verb, String url)
3938
try
4039
{
4140
connection = (HttpURLConnection) new URL(url).openConnection();
42-
if(timeout != null) connection.setConnectTimeout(timeout);
4341
} catch (IOException ioe)
4442
{
4543
throw new OAuthException("Could not open connection to: " + url, ioe);
@@ -212,13 +210,23 @@ public Map<String, String> getHeaders()
212210
}
213211

214212
/**
215-
* Sets the connection timeout in milliseconds for the underlying {@link HttpURLConnection}
213+
* Sets the connect timeout in milliseconds for the underlying {@link HttpURLConnection}
216214
*
217-
* @param timeout in milliseconds
215+
* @param connect timeout in milliseconds
218216
*/
219-
public void setTimeout(int timeout)
217+
public void setConnectTimeout(int timeout)
220218
{
221-
this.timeout = timeout;
219+
this.connection.setConnectTimeout(timeout);
220+
}
221+
222+
/**
223+
* Sets the read timeout in milliseconds for the underlying {@link HttpURLConnection}
224+
*
225+
* @param read timeout in milliseconds
226+
*/
227+
public void setReadTimeout(int timeout)
228+
{
229+
this.connection.setReadTimeout(timeout);
222230
}
223231

224232
/*

0 commit comments

Comments
 (0)