http timeouts von alten httpc wieder gesetzt

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4670 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
danielr 17 years ago
parent 2c1c3bb6eb
commit 7a35126e91

@ -174,6 +174,17 @@ public abstract class HttpClient {
public static byte[] wget(final String uri, final String vhost) {
return wget(uri, null, vhost);
}
/**
* Gets a page (as raw bytes) aborting after timeout
*
* @param uri
* @param timeout in milliseconds
* @return
*/
public static byte[] wget(final String uri, final int timeout) {
return wget(uri, null, null, timeout);
}
/**
* Gets a page (as raw bytes) with specified header
@ -196,8 +207,21 @@ public abstract class HttpClient {
* @assert uri != null
*/
public static byte[] wget(final String uri, httpHeader header, final String vhost) {
return wget(uri, header, vhost, 10000);
}
/**
* Gets a page (as raw bytes) addressing vhost at host in uri with specified header and timeout
*
* @param uri
* @param header
* @param vhost
* @param timeout in milliseconds
* @return
*/
public static byte[] wget(final String uri, httpHeader header, final String vhost, int timeout) {
assert uri != null : "precondition violated: uri != null";
final HttpClient client = HttpFactory.newClient();
final HttpClient client = HttpFactory.newClient(null, timeout);
// set header
header = addHostHeader(header, vhost);

@ -257,7 +257,7 @@ public final class indexRepositoryReference {
yacyURL newUrl = new yacyURL(newUrlStr, null);
// doing a http head request to test if the url is correct
HttpClient client = HttpFactory.newClient();
HttpClient client = HttpFactory.newClient(null, 30000);
client.setProxy(proxyConfig);
HttpResponse res = null;
try {

@ -141,7 +141,7 @@ public class loaderThreads {
public void run() {
try {
page = HttpClient.wget(url.toString());
page = HttpClient.wget(url.toString(), timeout);
loaded = true;
process.feed(page);
if (process.status() == loaderCore.STATUS_FAILED) {

@ -236,6 +236,7 @@ public final class yacyClient {
/**
* send data to the server named by vhost
*
* @param address address of the server
* @param vhost name of the server at address which should respond
* @param post data to send (name-value-pairs)
@ -243,7 +244,20 @@ public final class yacyClient {
* @throws IOException
*/
private static byte[] wput(final String url, String vhost, final Map<String, ?> post) throws IOException {
HttpClient client = HttpFactory.newClient(null, 3600000); // abort after 1 hour
return wput(url, vhost, post, 10000);
}
/**
* send data to the server named by vhost
*
* @param address address of the server
* @param vhost name of the server at address which should respond
* @param post data to send (name-value-pairs)
* @param timeout in milliseconds
* @return response body
* @throws IOException
*/
private static byte[] wput(final String url, String vhost, final Map<String, ?> post, final int timeout) throws IOException {
HttpClient client = HttpFactory.newClient(null, timeout);
client.setProxy(proxyConfig());
// address vhost
@ -363,7 +377,8 @@ public final class yacyClient {
// send request
try {
final byte[] result = wput("http://" + target.getClusterAddress() + "/yacy/urls.xml", target.getHexHash() + ".yacyh", post);
/* a long time-out is needed */
final byte[] result = wput("http://" + target.getClusterAddress() + "/yacy/urls.xml", target.getHexHash() + ".yacyh", post, 60000);
rssReader reader = rssReader.parse(result);
if (reader == null) {
@ -439,7 +454,7 @@ public final class yacyClient {
// send request
HashMap<String, String> result = null;
try {
result = nxTools.table(postToFile(target, "search.html", post), "UTF-8");
result = nxTools.table(wput("http://" + target.getClusterAddress() + "/yacy/search.html", target.getHexHash() + ".yacyh", post, 60000), "UTF-8");
} catch (IOException e) {
yacyCore.log.logInfo("SEARCH failed, Peer: " + target.hash + ":" + target.getName() + " (" + e.getMessage() + "), score=" + target.selectscore + ", DHTdist=" + yacyDHTAction.dhtDistance(target.hash, wordhashes.substring(0, 12)));
//yacyCore.peerActions.peerDeparture(target, "search request to peer created io exception: " + e.getMessage());
@ -724,7 +739,7 @@ public final class yacyClient {
try {
// TODO is targetAddress == url.getHost()?
final yacyURL url = new yacyURL("http://" + targetAddress + "/yacy/transfer.html", null);
final byte[] content = wput("http://" + targetAddress + "/yacy/transfer.html", url.getHost(), post);
final byte[] content = wput("http://" + targetAddress + "/yacy/transfer.html", url.getHost(), post, 20000);
final HashMap<String, String> result = nxTools.table(content, "UTF-8");
return result;
} catch (Exception e) {

@ -186,7 +186,7 @@ public class yacyPeerActions {
yacyCore.log.logInfo("BOOTSTRAP: seed-list URL " + seedListFileURL + " too old (" + (header.age() / 86400000) + " days)");
} else {
ssc++;
final byte[] content = HttpClient.wget(url.toString(), reqHeader);
final byte[] content = HttpClient.wget(url.toString(), reqHeader, null, bootstrapLoadTimeout);
seedList = nxTools.strings(content, "UTF-8");
enu = seedList.iterator();
lc = 0;

@ -328,7 +328,7 @@ public final class yacyVersion implements Comparator<yacyVersion>, Comparable<ya
File storagePath = plasmaSwitchboard.getSwitchboard().releasePath;
// load file
File download = new File(storagePath, release.url.getFileName());
HttpClient client = HttpFactory.newClient(null, 60000);
HttpClient client = HttpFactory.newClient(null, 300000);
HttpResponse res = null;
try {
res = client.GET(release.url.toString());

Loading…
Cancel
Save