Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
enhancements to http loading
Michael Peter Christena803c6063bcb
diff --git a/source/net/yacy/cora/protocol/http/HTTPClient.java b/source/net/yacy/cora/protocol/http/HTTPClient.javaindex f924fd1d2..015a13c36 100644--- a/source/net/yacy/cora/protocol/http/HTTPClient.java+++ b/source/net/yacy/cora/protocol/http/HTTPClient.java@@ -29,8 +29,6 @@ import java.io.Closeable;import java.io.IOException;import java.io.InputStream;import java.io.OutputStream;-import java.net.InetAddress;-import java.net.UnknownHostException;import java.security.KeyManagementException;import java.security.NoSuchAlgorithmException;import java.security.cert.CertificateException;@@ -40,12 +38,12 @@ import java.util.Locale;import java.util.Map;import java.util.Map.Entry;import java.util.Set;-import java.util.concurrent.Callable;import java.util.concurrent.ExecutionException;import java.util.concurrent.ExecutorService;import java.util.concurrent.Executors;import java.util.concurrent.FutureTask;import java.util.concurrent.TimeUnit;+import java.util.concurrent.TimeoutException;import java.util.concurrent.atomic.AtomicBoolean;import javax.net.ssl.SSLContext;@@ -64,7 +62,6 @@ import org.apache.http.HttpStatus;import org.apache.http.auth.AuthSchemeProvider;import org.apache.http.auth.AuthScope;import org.apache.http.auth.UsernamePasswordCredentials;-import org.apache.http.client.ClientProtocolException;import org.apache.http.client.CredentialsProvider;import org.apache.http.client.config.AuthSchemes;import org.apache.http.client.config.CookieSpecs;@@ -80,7 +77,6 @@ import org.apache.http.config.Registry;import org.apache.http.config.RegistryBuilder;import org.apache.http.config.SocketConfig;import org.apache.http.conn.ConnectionKeepAliveStrategy;-import org.apache.http.conn.DnsResolver;import org.apache.http.conn.routing.HttpRoute;import org.apache.http.conn.socket.ConnectionSocketFactory;import org.apache.http.conn.socket.PlainConnectionSocketFactory;@@ -167,12 +163,13 @@ public class HTTPClient implements Closeable {EXPIRED_CONNECTIONS_EVICTOR.start();}- private final static HttpClientBuilder clientBuilder = initClientBuilder();private final RequestConfig.Builder reqConfBuilder;private Set<Entry<String, String>> headers = null;private long upbytes = 0L;private String host = null;private final long timeout;+ private final HttpClientBuilder clientBuilder;+private static ExecutorService executor = Executors.newCachedThreadPool(new NamePrefixThreadFactory(HTTPClient.class.getSimpleName() + ".execute"));@@ -185,17 +182,19 @@ public class HTTPClient implements Closeable {public HTTPClient(final ClientIdentification.Agent agent) {super();this.timeout = agent.clientTimeout;- clientBuilder.setUserAgent(agent.userAgent);+ this.clientBuilder = initClientBuilder();+ this.clientBuilder.setUserAgent(agent.userAgent);this.reqConfBuilder = RequestConfig.copy(DFLTREQUESTCONFIG);- setTimout(agent.clientTimeout);+ this.setTimout(agent.clientTimeout);}public HTTPClient(final ClientIdentification.Agent agent, final int timeout) {super();this.timeout = timeout;- clientBuilder.setUserAgent(agent.userAgent);+ this.clientBuilder = initClientBuilder();+ this.clientBuilder.setUserAgent(agent.userAgent);this.reqConfBuilder = RequestConfig.copy(DFLTREQUESTCONFIG);- setTimout(timeout);+ this.setTimout(timeout);}private static RequestConfig initRequestConfig(int timeout) {@@ -251,13 +250,22 @@ public class HTTPClient implements Closeable {.register("http", plainsf).register("https", getSSLSocketFactory()).build();- final PoolingHttpClientConnectionManager pooling = new PoolingHttpClientConnectionManager(registry, null, null, new DnsResolver(){- @Override- public InetAddress[] resolve(final String host0)throws UnknownHostException {- final InetAddress ip = Domains.dnsResolve(host0);- if (ip == null) throw new UnknownHostException(host0);- return new InetAddress[]{ip};- }}, DEFAULT_POOLED_CONNECTION_TIME_TO_LIVE, TimeUnit.SECONDS);+ PoolingHttpClientConnectionManager pooling = new PoolingHttpClientConnectionManager(registry);+ /*+ final PoolingHttpClientConnectionManager pooling = new PoolingHttpClientConnectionManager(registry, null, null, host0 -> {+ final String qname = java.net.IDN.toASCII(host0);+ final InetAddress ip = Domains.dnsResolve(qname);+ if (ip == null) {+ UnknownHostException uhe = new UnknownHostException(qname + " (DNS resolve returned null)");+ // Optional: attach a hint for Unicode hosts+ if (!qname.equals(host0)) {+ uhe.addSuppressed(new RuntimeException("IDN note: original host='" + host0 + "', ascii='" + qname + "'"));+ }+ throw uhe;+ }+ return new InetAddress[]{ip};+ }, DEFAULT_POOLED_CONNECTION_TIME_TO_LIVE, TimeUnit.SECONDS);+ */initPoolMaxConnections(pooling, maxcon);pooling.setValidateAfterInactivity(default_timeout); // on init set to default 5000ms@@ -352,7 +360,7 @@ public class HTTPClient implements Closeable {* @param userAgent*/public void setUserAgent(final ClientIdentification.Agent agent) {- clientBuilder.setUserAgent(agent.userAgent);+ this.clientBuilder.setUserAgent(agent.userAgent);}/**@@ -386,7 +394,7 @@ public class HTTPClient implements Closeable {* @throws IOException*/public byte[] GETbytes(final String uri, final String username, final String pass, final boolean concurrent) throws IOException {- return GETbytes(uri, username, pass, Integer.MAX_VALUE, concurrent);+ return this.GETbytes(uri, username, pass, Integer.MAX_VALUE, concurrent);}/**@@ -401,7 +409,7 @@ public class HTTPClient implements Closeable {* @throws IOException*/public byte[] GETbytes(final MultiProtocolURL url, final String username, final String pass, final boolean concurrent) throws IOException {- return GETbytes(url, username, pass, Integer.MAX_VALUE, concurrent);+ return this.GETbytes(url, username, pass, Integer.MAX_VALUE, concurrent);}/**@@ -417,7 +425,7 @@ public class HTTPClient implements Closeable {* @throws IOException*/public byte[] GETbytes(final String uri, final String username, final String pass, final int maxBytes, final boolean concurrent) throws IOException {- return GETbytes(new MultiProtocolURL(uri), username, pass, maxBytes, concurrent);+ return this.GETbytes(new MultiProtocolURL(uri), username, pass, maxBytes, concurrent);}@@ -442,9 +450,9 @@ public class HTTPClient implements Closeable {} catch (final IllegalArgumentException e) {throw new IOException(e.getMessage()); // can be caused at java.net.URI.create()}- if (!localhost) setHost(url.getHost()); // overwrite resolved IP, needed for shared web hosting DO NOT REMOVE, see http://en.wikipedia.org/wiki/Shared_web_hosting_service+ if (!localhost) this.setHost(url.getHost()); // overwrite resolved IP, needed for shared web hosting DO NOT REMOVE, see http://en.wikipedia.org/wiki/Shared_web_hosting_serviceif (!localhost || pass == null) {- return getContentBytes(maxBytes, concurrent);+ return this.getContentBytes(maxBytes, concurrent);}final CredentialsProvider credsProvider = new BasicCredentialsProvider();@@ -452,12 +460,12 @@ public class HTTPClient implements Closeable {new AuthScope("localhost", url.getPort()),new UsernamePasswordCredentials(username, pass));- try (final CloseableHttpClient httpclient = clientBuilder.setDefaultCredentialsProvider(credsProvider)+ try (final CloseableHttpClient httpclient = this.clientBuilder.setDefaultCredentialsProvider(credsProvider).setDefaultAuthSchemeRegistry(AUTHSCHEMEREGISTRY).build()) {this.httpResponse = httpclient.execute(this.currentRequest);final HttpEntity httpEntity = this.httpResponse.getEntity();if (httpEntity != null) {- if (getStatusCode() == HttpStatus.SC_OK) {+ if (this.getStatusCode() == HttpStatus.SC_OK) {if (maxBytes >= 0 && httpEntity.getContentLength() > maxBytes) {/* When anticipated content length is already known and exceed the specified limit :* throw an exception and abort the connection, consistently with getByteArray() implementation@@ -468,7 +476,7 @@ public class HTTPClient implements Closeable {}}} finally {- close();+ this.close();}return null;}@@ -482,7 +490,7 @@ public class HTTPClient implements Closeable {* @throws IOException*/public void GET(final String uri, final boolean concurrent) throws IOException {- GET(new MultiProtocolURL(uri), concurrent);+ this.GET(new MultiProtocolURL(uri), concurrent);}/**@@ -502,9 +510,9 @@ public class HTTPClient implements Closeable {} catch (final IllegalArgumentException e) {throw new IOException(e.getMessage()); // can be caused at java.net.URI.create()}- setHost(url.getHost()); // overwrite resolved IP, needed for shared web hosting DO NOT REMOVE, see http://en.wikipedia.org/wiki/Shared_web_hosting_service+ this.setHost(url.getHost()); // overwrite resolved IP, needed for shared web hosting DO NOT REMOVE, see http://en.wikipedia.org/wiki/Shared_web_hosting_service- execute(concurrent);+ this.execute(concurrent);}/**@@ -515,7 +523,7 @@ public class HTTPClient implements Closeable {* @throws IOException*/public HttpResponse HEADResponse(final String uri, final boolean concurrent) throws IOException {- return HEADResponse(new MultiProtocolURL(uri), concurrent);+ return this.HEADResponse(new MultiProtocolURL(uri), concurrent);}/**@@ -527,8 +535,8 @@ public class HTTPClient implements Closeable {*/public HttpResponse HEADResponse(final MultiProtocolURL url, final boolean concurrent) throws IOException {this.currentRequest = new HttpHead(url.toNormalform(true));- setHost(url.getHost()); // overwrite resolved IP, needed for shared web hosting DO NOT REMOVE, see http://en.wikipedia.org/wiki/Shared_web_hosting_service- execute(concurrent);+ this.setHost(url.getHost()); // overwrite resolved IP, needed for shared web hosting DO NOT REMOVE, see http://en.wikipedia.org/wiki/Shared_web_hosting_service+ this.execute(concurrent);return this.httpResponse;}@@ -563,12 +571,12 @@ public class HTTPClient implements Closeable {this.currentRequest = new HttpPost(url.toNormalform(true));String host = url.getHost();if (host == null) host = Domains.LOCALHOST;- setHost(host); // overwrite resolved IP, needed for shared web hosting DO NOT REMOVE, see http://en.wikipedia.org/wiki/Shared_web_hosting_service+ this.setHost(host); // overwrite resolved IP, needed for shared web hosting DO NOT REMOVE, see http://en.wikipedia.org/wiki/Shared_web_hosting_servicefinal NonClosingInputStreamEntity inputStreamEntity = new NonClosingInputStreamEntity(instream, length);// statisticsthis.upbytes = length;((HttpPost) this.currentRequest).setEntity(inputStreamEntity);- execute(concurrent);+ this.execute(concurrent);}/**@@ -597,7 +605,7 @@ public class HTTPClient implements Closeable {* @throws IOException*/public byte[] POSTbytes(final MultiProtocolURL url, final String vhost, final Map<String, ContentBody> post, final boolean usegzip, final boolean concurrent) throws IOException {- return POSTbytes(url, vhost, post, null, null, usegzip, concurrent);+ return this.POSTbytes(url, vhost, post, null, null, usegzip, concurrent);}/**@@ -616,8 +624,8 @@ public class HTTPClient implements Closeable {final String userName, final String password, final boolean usegzip, final boolean concurrent) throws IOException {this.currentRequest = new HttpPost(url.toNormalform(true));final boolean localhost = Domains.isLocalhost(url.getHost());- if (!localhost) setHost(url.getHost()); // overwrite resolved IP, needed for shared web hosting DO NOT REMOVE, see http://en.wikipedia.org/wiki/Shared_web_hosting_service- if (vhost == null) setHost(Domains.LOCALHOST);+ if (!localhost) this.setHost(url.getHost()); // overwrite resolved IP, needed for shared web hosting DO NOT REMOVE, see http://en.wikipedia.org/wiki/Shared_web_hosting_service+ if (vhost == null) this.setHost(Domains.LOCALHOST);final MultipartEntityBuilder entityBuilder = MultipartEntityBuilder.create();for (final Entry<String,ContentBody> part : post.entrySet()) entityBuilder.addPart(part.getKey(), part.getValue());@@ -632,7 +640,7 @@ public class HTTPClient implements Closeable {}if (!localhost || password == null) {- return getContentBytes(Integer.MAX_VALUE, concurrent);+ return this.getContentBytes(Integer.MAX_VALUE, concurrent);}final CredentialsProvider credsProvider = new BasicCredentialsProvider();@@ -640,17 +648,17 @@ public class HTTPClient implements Closeable {new AuthScope("localhost", url.getPort()),new UsernamePasswordCredentials(userName, password));- try (final CloseableHttpClient httpclient = clientBuilder.setDefaultCredentialsProvider(credsProvider)+ try (final CloseableHttpClient httpclient = this.clientBuilder.setDefaultCredentialsProvider(credsProvider).setDefaultAuthSchemeRegistry(AUTHSCHEMEREGISTRY).build()) {this.httpResponse = httpclient.execute(this.currentRequest);final HttpEntity httpEntity = this.httpResponse.getEntity();if (httpEntity != null) {- if (getStatusCode() == HttpStatus.SC_OK) {+ if (this.getStatusCode() == HttpStatus.SC_OK) {return getByteArray(httpEntity, Integer.MAX_VALUE);}}} finally {- close();+ this.close();}return null;}@@ -778,7 +786,7 @@ public class HTTPClient implements Closeable {if (httpEntity != null) try {return httpEntity.getContent();} catch (final IOException e) {- close();+ this.close();throw e;}}@@ -799,7 +807,7 @@ public class HTTPClient implements Closeable {httpEntity.writeTo(outputStream);outputStream.flush();} finally {- close();+ this.close();}}}@@ -832,12 +840,12 @@ public class HTTPClient implements Closeable {private byte[] getContentBytes(final int maxBytes, final boolean concurrent) throws IOException {try {- execute(concurrent);+ this.execute(concurrent);if (this.httpResponse == null) return null;// get the response bodyfinal HttpEntity httpEntity = this.httpResponse.getEntity();if (httpEntity != null) {- if (getStatusCode() == HttpStatus.SC_OK) {+ if (this.getStatusCode() == HttpStatus.SC_OK) {if (maxBytes >= 0 && httpEntity.getContentLength() > maxBytes) {/* When anticipated content length is already known and exceed the specified limit :* throw an exception and abort the connection, consistently with getByteArray() implementation@@ -848,7 +856,7 @@ public class HTTPClient implements Closeable {}}} finally {- close();+ this.close();}return null;}@@ -856,12 +864,11 @@ public class HTTPClient implements Closeable {private void execute(final boolean concurrent) throws IOException {final HttpClientContext context = HttpClientContext.create();context.setRequestConfig(this.reqConfBuilder.build());- if (this.host != null)- context.setTargetHost(new HttpHost(this.host));+ //if (this.host != null) context.setTargetHost(new HttpHost(this.host));- setHeaders();+ this.setHeaders();// statistics- storeConnectionInfo();+ this.storeConnectionInfo();// execute the method; some asserts confirm that that the request can be send with Content-Length and is therefore not terminated by EOFif (this.currentRequest instanceof HttpEntityEnclosingRequest) {final HttpEntityEnclosingRequest hrequest = (HttpEntityEnclosingRequest) this.currentRequest;@@ -878,44 +885,153 @@ public class HTTPClient implements Closeable {final long time = System.currentTimeMillis();try {- this.client = clientBuilder.build();+ this.client = this.clientBuilder.build();if (concurrent) {- final FutureTask<CloseableHttpResponse> t = new FutureTask<CloseableHttpResponse>(new Callable<CloseableHttpResponse>() {- @Override- public CloseableHttpResponse call() throws ClientProtocolException, IOException {- final CloseableHttpResponse response = HTTPClient.this.client.execute(HTTPClient.this.currentRequest, context);- return response;- }+ final FutureTask<CloseableHttpResponse> t = new FutureTask<>(() -> {+ final CloseableHttpResponse response = HTTPClient.this.client.execute(HTTPClient.this.currentRequest, context);+ return response;});executor.execute(t);try {this.httpResponse = t.get(this.timeout, TimeUnit.MILLISECONDS);- } catch (final ExecutionException e) {- throw e.getCause();- } catch (final Throwable e) {}- try {t.cancel(true);} catch (final Throwable e) {}- if (this.httpResponse == null) {- throw new IOException("timout to client after " + this.timeout + "ms" + " for url " + uri);+ } catch (ExecutionException e) {+ Throwable c = e.getCause();+ if (c instanceof IOException) throw (IOException) c;+ throw new IOException(c == null ? e : c);+ } catch (TimeoutException e) {+ t.cancel(true);+ throw new IOException("timeout after " + this.timeout + " ms for url " + uri, e);+ } catch (InterruptedException e) {+ Thread.currentThread().interrupt();+ throw new IOException("interrupted while executing " + uri, e);}} else {this.httpResponse = this.client.execute(this.currentRequest, context);}this.httpResponse.setHeader(HeaderFramework.RESPONSE_TIME_MILLIS, Long.toString(System.currentTimeMillis() - time));} catch (final Throwable e) {- long runtime = System.currentTimeMillis() - time;- close();- throw new IOException("Client can't execute: "- + (e.getCause() == null ? e.getMessage() : e.getCause().getMessage())- + ", timeout=" + this.timeout- + ", duration=" + Long.toString(runtime)- + ", concurrent=" + Boolean.toString(concurrent)- + ", url=" + uri);+ final long runtime = System.currentTimeMillis() - time;++ // Build rich diagnostics+ final String diag = buildDiagnostics(+ e,+ this.currentRequest,+ context,+ this.host,+ this.timeout,+ concurrent,+ runtime+ );++ // Ensure resources are closed before bubbling up+ try { this.close(); } catch (IOException ignore) {}++ // Preserve the original stack as cause+ final IOException io = (e instanceof IOException) ? (IOException) e+ : new IOException(e.getMessage(), e);++ throw new IOException(diag, io);} finally {/* Restore the thread initial name */Thread.currentThread().setName(initialThreadName);}}+ private static String buildDiagnostics(+ Throwable e,+ HttpUriRequest req,+ HttpClientContext ctx,+ String vhost,+ long timeoutMs,+ boolean concurrent,+ long durationMs) {++ final StringBuilder sb = new StringBuilder(256);++ // 1) Exception chain (class: message -> root cause)+ sb.append("HTTPClient failure: ")+ .append(exceptionChain(e));++ // 2) Request line & basic info+ String method = req != null ? req.getMethod() : "?";+ String url = req != null && req.getURI() != null ? req.getURI().toString() : "?";+ sb.append(" | request=").append(method).append(" ").append(url);++ // 3) Target & routing+ HttpHost target = ctx != null ? ctx.getTargetHost() : null;+ if (target != null) {+ sb.append(" | target=").append(target.toURI());+ }++ // Route (proxy? TLS? direct?)+ try {+ org.apache.http.conn.routing.HttpRoute route =+ (org.apache.http.conn.routing.HttpRoute) (ctx != null ? ctx.getAttribute(HttpClientContext.HTTP_ROUTE) : null);+ if (route != null) {+ sb.append(" | route=").append(route.toString());+ if (route.getProxyHost() != null) sb.append(" viaProxy=").append(route.getProxyHost());+ }+ } catch (Throwable ignore) {}++ // 4) Virtual host/SNI intent+ if (vhost != null) sb.append(" | vhost=").append(vhost);+ sb.append(" | sniEnabled=").append(ENABLE_SNI_EXTENSION.get());++ // 5) DNS quick hint (best-effort)+ try {+ String host = req != null && req.getURI() != null ? req.getURI().getHost() : null;+ if (host != null) {+ java.net.InetAddress ip = net.yacy.cora.protocol.Domains.dnsResolve(host);+ if (ip != null) sb.append(" | resolvedIp=").append(ip.getHostAddress());+ }+ } catch (Throwable ignore) {}++ // 6) Timeouts & duration+ sb.append(" | timeouts(ms){connect=")+ .append(reqConfValue(ctx, "http.socket.timeout", "socket")) // best-effort+ .append(", lease=")+ .append(reqConfValue(ctx, "http.connection-request.timeout", "lease"))+ .append(", connect=")+ .append(reqConfValue(ctx, "http.connection.timeout", "connect"))+ .append("} | deadline=").append(timeoutMs)+ .append(" | duration=").append(durationMs)+ .append(" | concurrent=").append(concurrent);++ return sb.toString();+ }++ /** Render exception class chain succinctly: IOException(ConnectException: Connection refused) … */+ private static String exceptionChain(Throwable e) {+ StringBuilder sb = new StringBuilder();+ int depth = 0;+ while (e != null && depth < 5) {+ if (depth > 0) sb.append(" -> ");+ sb.append(e.getClass().getSimpleName());+ String msg = e.getMessage();+ if (msg != null && !msg.isEmpty()) {+ sb.append(": ").append(msg);+ }+ e = e.getCause();+ depth++;+ }+ return sb.toString();+ }++ /** Best-effort extraction of timeouts from the context; falls back to "n/a". */+ private static String reqConfValue(HttpClientContext ctx, String key, String label) {+ try {+ RequestConfig rc = ctx != null ? ctx.getRequestConfig() : null;+ if (rc != null) {+ switch (label) {+ case "socket": return String.valueOf(rc.getSocketTimeout());+ case "lease": return String.valueOf(rc.getConnectionRequestTimeout());+ case "connect": return String.valueOf(rc.getConnectTimeout());+ }+ }+ } catch (Throwable ignore) {}+ return "n/a";+ }+/*** Return entity content loaded as a byte array* @param entity HTTP entity@@ -979,7 +1095,8 @@ public class HTTPClient implements Closeable {this.currentRequest.setHeader(entry.getKey(),entry.getValue());}}- if (this.host != null) this.currentRequest.setHeader(HTTP.TARGET_HOST, this.host);+ if (this.host != null) this.currentRequest.setHeader(HttpHeaders.HOST, this.host);+this.currentRequest.setHeader(HTTP.CONN_DIRECTIVE, "close"); // don't keep alive, prevent CLOSE_WAIT state}@@ -999,18 +1116,16 @@ public class HTTPClient implements Closeable {private static SSLConnectionSocketFactory getSSLSocketFactory() {final TrustManager trustManager = new X509TrustManager() {@Override- public void checkClientTrusted(final X509Certificate[] chain, final String authType)- throws CertificateException {+ public void checkClientTrusted(final X509Certificate[] chain, final String authType) throws CertificateException {}@Override- public void checkServerTrusted(final X509Certificate[] chain, final String authType)- throws CertificateException {+ public void checkServerTrusted(final X509Certificate[] chain, final String authType) throws CertificateException {}@Overridepublic X509Certificate[] getAcceptedIssuers() {- return null;+ return new X509Certificate[0];}};SSLContext sslContext = null;@@ -1025,13 +1140,11 @@ public class HTTPClient implements Closeable {// e.printStackTrace();}- return new SSLConnectionSocketFactory(- sslContext,- new NoopHostnameVerifier()) {+ return new SSLConnectionSocketFactory(sslContext, NoopHostnameVerifier.INSTANCE) {@Overrideprotected void prepareSocket(final SSLSocket socket) throws IOException {- if(!ENABLE_SNI_EXTENSION.get()) {+ if (!ENABLE_SNI_EXTENSION.get()) {/* Set the SSLParameters server names to empty so we don't use SNI extension.* See https://docs.oracle.com/javase/8/docs/technotes/guides/security/jsse/JSSERefGuide.html#ClientSNIExamples */final SSLParameters sslParams = socket.getSSLParameters();@@ -1040,6 +1153,7 @@ public class HTTPClient implements Closeable {}}};+}/**diff --git a/source/net/yacy/crawler/retrieval/HTTPLoader.java b/source/net/yacy/crawler/retrieval/HTTPLoader.javaindex 689e6f1b1..c5e7ef09c 100644--- a/source/net/yacy/crawler/retrieval/HTTPLoader.java+++ b/source/net/yacy/crawler/retrieval/HTTPLoader.java@@ -82,7 +82,7 @@ public final class HTTPLoader {// load fulltext of html pageLatency.updateBeforeLoad(entry.url());final long start = System.currentTimeMillis();- final Response doc = load(entry, profile, DEFAULT_CRAWLING_RETRY_COUNT, maxFileSize, blacklistType, agent);+ final Response doc = this.load(entry, profile, DEFAULT_CRAWLING_RETRY_COUNT, maxFileSize, blacklistType, agent);Latency.updateAfterLoad(entry.url(), System.currentTimeMillis() - start);return doc;}@@ -137,7 +137,7 @@ public final class HTTPLoader {}// create a request header- final RequestHeader requestHeader = createRequestheader(request, agent);+ final RequestHeader requestHeader = this.createRequestheader(request, agent);// HTTP-Clienttry (final HTTPClient client = new HTTPClient(agent)) {@@ -158,7 +158,7 @@ public final class HTTPLoader {if (statusCode > 299 && statusCode < 310) {// client.close(); // explicit close caused: warning: [try] explicit call to close() on an auto-closeable resource- final DigestURL redirectionUrl = extractRedirectURL(request, profile, url, statusline, responseHeader, requestURLString);+ final DigestURL redirectionUrl = this.extractRedirectURL(request, profile, url, statusline, responseHeader, requestURLString);if (this.sb.getConfigBool(SwitchboardConstants.CRAWLER_FOLLOW_REDIRECTS, true)) {// we have two use cases here: loading from a crawl or just@@ -204,7 +204,7 @@ public final class HTTPLoader {// retry crawling with new urlrequest.redirectURL(redirectionUrl);- return openInputStream(request, profile, retryCount - 1, maxFileSize, blacklistType, agent);+ return this.openInputStream(request, profile, retryCount - 1, maxFileSize, blacklistType, agent);}// we don't want to follow redirectsthis.sb.crawlQueues.errorURL.push(request.url(), request.depth(), profile, FailCategory.FINAL_PROCESS_CONTEXT, "redirection not wanted", statusCode);@@ -310,19 +310,16 @@ public final class HTTPLoader {final RequestHeader requestHeader = new RequestHeader();requestHeader.put(HeaderFramework.USER_AGENT, agent.userAgent);if (request.referrerhash() != null) {- String refererURL = this.sb.getURL(request.referrerhash());- if (refererURL != null) {- requestHeader.put(RequestHeader.REFERER, refererURL);- }+ String refererURL = this.sb.getURL(request.referrerhash());+ if (refererURL != null) {+ requestHeader.put(RequestHeader.REFERER, refererURL);+ }}requestHeader.put(HeaderFramework.ACCEPT, this.sb.getConfig("crawler.http.accept", DEFAULT_ACCEPT));- requestHeader.put(HeaderFramework.ACCEPT_LANGUAGE,- this.sb.getConfig("crawler.http.acceptLanguage", DEFAULT_LANGUAGE));- requestHeader.put(HeaderFramework.ACCEPT_CHARSET,- this.sb.getConfig("crawler.http.acceptCharset", DEFAULT_CHARSET));- requestHeader.put(HeaderFramework.ACCEPT_ENCODING,- this.sb.getConfig("crawler.http.acceptEncoding", DEFAULT_ENCODING));+ requestHeader.put(HeaderFramework.ACCEPT_LANGUAGE, this.sb.getConfig("crawler.http.acceptLanguage", DEFAULT_LANGUAGE));+ requestHeader.put(HeaderFramework.ACCEPT_CHARSET, this.sb.getConfig("crawler.http.acceptCharset", DEFAULT_CHARSET));+ requestHeader.put(HeaderFramework.ACCEPT_ENCODING, this.sb.getConfig("crawler.http.acceptEncoding", DEFAULT_ENCODING));return requestHeader;}@@ -362,7 +359,7 @@ public final class HTTPLoader {Response response = null;// create a request header- final RequestHeader requestHeader = createRequestheader(request, agent);+ final RequestHeader requestHeader = this.createRequestheader(request, agent);// HTTP-Clienttry (final HTTPClient client = new HTTPClient(agent)) {@@ -379,7 +376,7 @@ public final class HTTPLoader {// check redirectionif (statusCode > 299 && statusCode < 310) {- final DigestURL redirectionUrl = extractRedirectURL(request, profile, url, client.getHttpResponse().getStatusLine(),+ final DigestURL redirectionUrl = this.extractRedirectURL(request, profile, url, client.getHttpResponse().getStatusLine(),responseHeader, requestURLString);if (this.sb.getConfigBool(SwitchboardConstants.CRAWLER_FOLLOW_REDIRECTS, true)) {@@ -412,7 +409,7 @@ public final class HTTPLoader {// retry crawling with new urlrequest.redirectURL(redirectionUrl);- return load(request, profile, retryCount - 1, maxFileSize, blacklistType, agent);+ return this.load(request, profile, retryCount - 1, maxFileSize, blacklistType, agent);}// we don't want to follow redirectsthis.sb.crawlQueues.errorURL.push(request.url(), request.depth(), profile, FailCategory.FINAL_PROCESS_CONTEXT, "redirection not wanted", statusCode);@@ -483,7 +480,6 @@ public final class HTTPLoader {final RequestHeader requestHeader = new RequestHeader();requestHeader.put(HeaderFramework.USER_AGENT, agent.userAgent);requestHeader.put(HeaderFramework.ACCEPT_LANGUAGE, DEFAULT_LANGUAGE);- requestHeader.put(HeaderFramework.ACCEPT_CHARSET, DEFAULT_CHARSET);requestHeader.put(HeaderFramework.ACCEPT_ENCODING, DEFAULT_ENCODING);try (final HTTPClient client = new HTTPClient(agent)) {