From: <bra...@us...> - 2009-07-17 23:53:48
|
Revision: 2768 http://archive-access.svn.sourceforge.net/archive-access/?rev=2768&view=rev Author: bradtofel Date: 2009-07-17 23:53:43 +0000 (Fri, 17 Jul 2009) Log Message: ----------- FEATURE(ACC-38): now times out requests to remote ResourceIndexes. Modified Paths: -------------- branches/wayback-1_4_2/wayback-core/src/main/java/org/archive/wayback/resourceindex/RemoteResourceIndex.java Modified: branches/wayback-1_4_2/wayback-core/src/main/java/org/archive/wayback/resourceindex/RemoteResourceIndex.java =================================================================== --- branches/wayback-1_4_2/wayback-core/src/main/java/org/archive/wayback/resourceindex/RemoteResourceIndex.java 2009-07-17 23:52:26 UTC (rev 2767) +++ branches/wayback-1_4_2/wayback-core/src/main/java/org/archive/wayback/resourceindex/RemoteResourceIndex.java 2009-07-17 23:53:43 UTC (rev 2768) @@ -26,6 +26,8 @@ import java.io.File; import java.io.IOException; +import java.net.URL; +import java.net.URLConnection; import java.util.logging.Logger; import javax.xml.parsers.DocumentBuilder; @@ -71,7 +73,10 @@ .class.getName()); private String searchUrlBase; - + private int connectTimeout = 10000; + private int readTimeout = 10000; + + private DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); private static final String WB_XML_REQUEST_TAGNAME = "request"; @@ -333,7 +338,11 @@ // do an HTTP request, plus parse the result into an XML DOM protected Document getHttpDocument(String url) throws IOException, SAXException { - return (getDocumentBuilder()).parse(url); + URL u = new URL(url); + URLConnection conn = u.openConnection(); + conn.setConnectTimeout(connectTimeout); + conn.setReadTimeout(readTimeout); + return (getDocumentBuilder()).parse(conn.getInputStream(),url); } protected Document getFileDocument(File f) throws IOException, SAXException { @@ -365,4 +374,19 @@ public void setCanonicalizer(UrlCanonicalizer canonicalizer) { this.canonicalizer = canonicalizer; } + public int getConnectTimeout() { + return connectTimeout; + } + + public void setConnectTimeout(int connectTimeout) { + this.connectTimeout = connectTimeout; + } + + public int getReadTimeout() { + return readTimeout; + } + + public void setReadTimeout(int readTimeout) { + this.readTimeout = readTimeout; + } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |