[jsword-svn] r1861 - trunk/common/src/main/java/org/crosswire/common/util
dmsmith at www.crosswire.org
dmsmith at www.crosswire.org
Wed May 14 08:54:34 MST 2008
Author: dmsmith
Date: 2008-05-14 08:54:32 -0700 (Wed, 14 May 2008)
New Revision: 1861
Modified:
trunk/common/src/main/java/org/crosswire/common/util/WebResource.java
Log:
Added a 3/4 second timeout to the getting of a connection.
Modified: trunk/common/src/main/java/org/crosswire/common/util/WebResource.java
===================================================================
--- trunk/common/src/main/java/org/crosswire/common/util/WebResource.java 2008-05-13 22:04:09 UTC (rev 1860)
+++ trunk/common/src/main/java/org/crosswire/common/util/WebResource.java 2008-05-14 15:54:32 UTC (rev 1861)
@@ -29,6 +29,7 @@
import org.apache.commons.httpclient.HostConfiguration;
import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpConnectionManager;
import org.apache.commons.httpclient.HttpHost;
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.httpclient.HttpStatus;
@@ -62,8 +63,16 @@
{
uri = theURI;
client = new HttpClient();
+
+ // Set a 2 second timeout on getting a connection.
+ HttpConnectionManager connectMgr = client.getHttpConnectionManager();
+ connectMgr.getParams().setConnectionTimeout(TIMEOUT);
+
+ // Configure the host and port
HostConfiguration config = client.getHostConfiguration();
config.setHost(new HttpHost(theURI.getHost(), theURI.getPort()));
+
+ // Configure proxy info if necessary and defined
if (theProxyHost != null && theProxyHost.length() > 0)
{
config.setProxyHost(new ProxyHost(theProxyHost, theProxyPort == null ? -1 : theProxyPort.intValue()));
@@ -185,6 +194,11 @@
}
}
+ /**
+ * Define a 750 ms timeout to get a connection
+ */
+ private static final int TIMEOUT = 750;
+
private URI uri;
private HttpClient client;
}
More information about the jsword-svn
mailing list