From 3e7291eaee8dd971efefc9caaca364d4cfbdf00f Mon Sep 17 00:00:00 2001 From: Jamie Tsao Date: Thu, 4 Nov 2010 15:23:19 -0400 Subject: [PATCH] Added methods to allow for setting the connect and read timeouts on the underlying HttpURLConnection --- src/main/java/org/scribe/model/Request.java | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/scribe/model/Request.java b/src/main/java/org/scribe/model/Request.java index 9052bca..c94b7d7 100644 --- a/src/main/java/org/scribe/model/Request.java +++ b/src/main/java/org/scribe/model/Request.java @@ -21,7 +21,6 @@ class Request private Map bodyParams; private Map headers; private String payload = null; - private Integer timeout = null; private HttpURLConnection connection; /** @@ -39,7 +38,6 @@ class Request try { connection = (HttpURLConnection) new URL(url).openConnection(); - if(timeout != null) connection.setConnectTimeout(timeout); } catch (IOException 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); } /*