Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
fixed a bug in HTTPClient: keep-alive must be set to false, otherwise servers hold connections 2 seconds open until response.
orbiter57024191940f
diff --git a/source/de/anomic/http/server/HTTPDemon.java b/source/de/anomic/http/server/HTTPDemon.javaindex 751e34271..cf830896c 100644--- a/source/de/anomic/http/server/HTTPDemon.java+++ b/source/de/anomic/http/server/HTTPDemon.java@@ -821,14 +821,14 @@ public final class HTTPDemon implements serverHandler, Cloneable {// parse data in memoryFileUpload upload = new FileUpload(diskFileItemFactory);List<FileItem> items;- long time = System.currentTimeMillis();+ //long time = System.currentTimeMillis();try {items = upload.parseRequest(request);} catch (FileUploadException e) {//Log.logException(e);throw new IOException("FileUploadException " + e.getMessage());}- System.out.println("**** FileUploadBase.parseRequest time = " + (System.currentTimeMillis() - time));+ //System.out.println("**** FileUploadBase.parseRequest time = " + (System.currentTimeMillis() - time));// format information for further usagefinal HashMap<String, byte[]> files = new HashMap<String, byte[]>();diff --git a/source/net/yacy/cora/protocol/http/HTTPClient.java b/source/net/yacy/cora/protocol/http/HTTPClient.javaindex 279c33039..422fab54e 100644--- a/source/net/yacy/cora/protocol/http/HTTPClient.java+++ b/source/net/yacy/cora/protocol/http/HTTPClient.java@@ -46,6 +46,7 @@ import net.yacy.cora.protocol.ConnectionInfo;import org.apache.http.Header;import org.apache.http.HttpEntity;+import org.apache.http.HttpEntityEnclosingRequest;import org.apache.http.HttpHost;import org.apache.http.HttpResponse;import org.apache.http.HttpVersion;@@ -141,7 +142,7 @@ public class HTTPClient {HttpProtocolParams.setVersion(httpParams, HttpVersion.HTTP_1_1);// UserAgentHttpProtocolParams.setUserAgent(httpParams, "yacy (" + systemOST +") yacy.net");- HttpProtocolParams.setUseExpectContinue(httpParams, true);+ HttpProtocolParams.setUseExpectContinue(httpParams, false); // IMPORTANT - if not set to 'false' then servers do not process the request until a time-out of 2 seconds/*** HTTP connection settings*/@@ -473,9 +474,18 @@ public class HTTPClient {// statisticsstoreConnectionInfo(httpUriRequest);try {- // execute the method+ // execute the method; some asserts confirm that that the request can be send with Content-Length and is therefore not terminated by EOF+ if (httpUriRequest instanceof HttpEntityEnclosingRequest) {+ HttpEntityEnclosingRequest hrequest = (HttpEntityEnclosingRequest) httpUriRequest;+ HttpEntity entity = hrequest.getEntity();+ assert entity != null;+ assert !entity.isChunked();+ assert entity.getContentLength() >= 0;+ assert !hrequest.expectContinue();+ }httpResponse = httpClient.execute(httpUriRequest, httpContext);} catch (Exception e) {+ //e.printStackTrace();ConnectionInfo.removeConnection(httpUriRequest.hashCode());httpUriRequest.abort();throw new IOException("Client can't execute: " + e.getMessage());diff --git a/source/net/yacy/yacy.java b/source/net/yacy/yacy.javaindex 135278a75..b178cc59b 100644--- a/source/net/yacy/yacy.java+++ b/source/net/yacy/yacy.java@@ -290,7 +290,6 @@ public final class yacy {// set user-agentfinal String userAgent = "yacy/" + Double.toString(version) + " (www.yacy.net; "+ HTTPClient.getSystemOST() + ")";-// Client.setUserAgent(userAgent);HTTPClient.setDefaultUserAgent(userAgent);// start main threads