From cd4d891ea4e03c946fbf10047f49fd012abe0b49 Mon Sep 17 00:00:00 2001 From: reger Date: Sat, 4 Mar 2017 19:41:31 +0100 Subject: [PATCH] use pre-defined "Connection" header key, replace depreceated --- .../net/yacy/cora/federate/solr/instance/RemoteInstance.java | 5 +++-- source/net/yacy/cora/protocol/http/HTTPClient.java | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/source/net/yacy/cora/federate/solr/instance/RemoteInstance.java b/source/net/yacy/cora/federate/solr/instance/RemoteInstance.java index 8f9a801c8..b8622b1e1 100644 --- a/source/net/yacy/cora/federate/solr/instance/RemoteInstance.java +++ b/source/net/yacy/cora/federate/solr/instance/RemoteInstance.java @@ -50,6 +50,7 @@ import org.apache.http.auth.UsernamePasswordCredentials; import org.apache.http.client.AuthCache; import org.apache.http.client.entity.GzipDecompressingEntity; import org.apache.http.impl.auth.BasicScheme; +import org.apache.http.protocol.HTTP; import org.apache.http.protocol.HttpContext; import org.apache.solr.client.solrj.SolrClient; import org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrClient; @@ -140,7 +141,7 @@ public class RemoteInstance implements SolrInstance { BasicScheme basicAuth = new BasicScheme(); HttpHost targetHost = new HttpHost(u.getHost(), u.getPort(), u.getProtocol()); authCache.put(targetHost, basicAuth); - context.setAttribute(org.apache.http.client.protocol.ClientContext.AUTH_CACHE, authCache); + context.setAttribute(org.apache.http.client.protocol.HttpClientContext.AUTH_CACHE, authCache); this.setHttpRequestRetryHandler(new org.apache.http.impl.client.DefaultHttpRequestRetryHandler(0, false)); // no retries needed; we expect connections to fail; therefore we should not retry return context; } @@ -152,7 +153,7 @@ public class RemoteInstance implements SolrInstance { @Override public void process(final HttpRequest request, final HttpContext context) throws IOException { if (!request.containsHeader(HeaderFramework.ACCEPT_ENCODING)) request.addHeader(HeaderFramework.ACCEPT_ENCODING, HeaderFramework.CONTENT_ENCODING_GZIP); - if (!request.containsHeader("Connection")) request.addHeader("Connection", "close"); // prevent CLOSE_WAIT + if (!request.containsHeader(HTTP.CONN_DIRECTIVE)) request.addHeader(HTTP.CONN_DIRECTIVE, "close"); // prevent CLOSE_WAIT } }); diff --git a/source/net/yacy/cora/protocol/http/HTTPClient.java b/source/net/yacy/cora/protocol/http/HTTPClient.java index fdb092a89..662cae4d7 100644 --- a/source/net/yacy/cora/protocol/http/HTTPClient.java +++ b/source/net/yacy/cora/protocol/http/HTTPClient.java @@ -852,7 +852,7 @@ public class HTTPClient { } } if (this.host != null) httpUriRequest.setHeader(HTTP.TARGET_HOST, this.host); - httpUriRequest.setHeader("Connection", "close"); // don't keep alive, prevent CLOSE_WAIT state + httpUriRequest.setHeader(HTTP.CONN_DIRECTIVE, "close"); // don't keep alive, prevent CLOSE_WAIT state } private void storeConnectionInfo(final HttpUriRequest httpUriRequest) {