always use HTTPClient by 'try with resources' pattern to free up

resources
pull/436/head
sgaebel 4 years ago
parent 69adaa9f55
commit cdf901270c

@ -196,11 +196,10 @@ public class IndexImportMediawiki_p {
* @return the last modified date for the file at fileURL, or 0L when unknown or when an error occurred
*/
private static long getLastModified(MultiProtocolURL fileURL) {
long lastModified = 0l;
try {
if (fileURL.isHTTP() || fileURL.isHTTPS()) {
/* http(s) : we do not use MultiprotocolURL.lastModified() which always returns 0L for these protocols */
HTTPClient httpClient = new HTTPClient(ClientIdentification.yacyInternetCrawlerAgent);
try (HTTPClient httpClient = new HTTPClient(ClientIdentification.yacyInternetCrawlerAgent)) {
HttpResponse headResponse = httpClient.HEADResponse(fileURL, false);
if (headResponse != null && headResponse.getStatusLine() != null
&& headResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
@ -209,16 +208,17 @@ public class IndexImportMediawiki_p {
if (lastModifiedHeader != null) {
Date lastModifiedDate = HeaderFramework.parseHTTPDate(lastModifiedHeader.getValue());
if(lastModifiedDate != null) {
lastModified = lastModifiedDate.getTime();
return lastModifiedDate.getTime();
}
}
}
}
} else {
lastModified = fileURL.lastModified();
return fileURL.lastModified();
}
} catch (IOException ignored) {
ConcurrentLog.warn("IndexImportMediawiki_p", "Could not retrieve last modified date for dump file at " + fileURL);
}
return lastModified;
return 0l;
}
}

@ -2538,7 +2538,7 @@ public class MultiProtocolURL implements Serializable, Comparable<MultiProtocolU
return new ByteArrayInputStream(b);
}
if (isHTTP() || isHTTPS()) {
final HTTPClient client = new HTTPClient(agent);
try (final HTTPClient client = new HTTPClient(agent)){
client.setHost(getHost());
client.GET(this, false);
if (client.getStatusCode() != HttpStatus.SC_OK) {
@ -2547,6 +2547,7 @@ public class MultiProtocolURL implements Serializable, Comparable<MultiProtocolU
}
return new HTTPInputStream(client);
}
}
return null;
}
@ -2562,10 +2563,11 @@ public class MultiProtocolURL implements Serializable, Comparable<MultiProtocolU
return b;
}
if (isHTTP() || isHTTPS()) {
final HTTPClient client = new HTTPClient(agent);
try (final HTTPClient client = new HTTPClient(agent)) {
client.setHost(getHost());
return client.GETbytes(this, username, pass, false);
}
}
return null;
}

@ -297,10 +297,9 @@ public class OpenSearchConnector extends AbstractFederateSearchConnector impleme
String searchurl = this.parseSearchTemplate(baseurl, searchTerms, startIndex, count);
try {
DigestURL aurl = new DigestURL(searchurl);
try {
try (final HTTPClient httpClient = new HTTPClient(ClientIdentification.yacyInternetCrawlerAgent)) {
this.lastaccesstime = System.currentTimeMillis();
final HTTPClient httpClient = new HTTPClient(ClientIdentification.yacyInternetCrawlerAgent);
byte[] result = httpClient.GETbytes(aurl, null, null, false);
if(result == null) {

@ -121,8 +121,9 @@ public class SRURSSConnector {
parts.put("resource", UTF8.StringBody(global ? "global" : "local"));
parts.put("nav", UTF8.StringBody("none"));
// result = HTTPConnector.getConnector(userAgent == null ? MultiProtocolURI.yacybotUserAgent : userAgent).post(new MultiProtocolURI(rssSearchServiceURL), (int) timeout, uri.getHost(), parts);
final HTTPClient httpClient = new HTTPClient(agent);
try (final HTTPClient httpClient = new HTTPClient(agent)) {
result = httpClient.POSTbytes(new MultiProtocolURL(rssSearchServiceURL), uri.getHost(), parts, false, false);
}
final RSSReader reader = RSSReader.parse(RSSFeed.DEFAULT_MAXSIZE, result);
if (reader == null) {

@ -49,7 +49,7 @@ public class Network {
*/
public static Peers getNetwork(final String address) throws IOException {
Peers peers = new Peers();
final HTTPClient httpclient = new HTTPClient(ClientIdentification.yacyInternetCrawlerAgent);
try (final HTTPClient httpclient = new HTTPClient(ClientIdentification.yacyInternetCrawlerAgent)) {
final byte[] content = httpclient.GETbytes("http://" + address + "/Network.xml?page=1&maxCount=1000&ip=", null, null, false);
ByteArrayInputStream bais = new ByteArrayInputStream(content);
Document doc = null;
@ -74,6 +74,7 @@ public class Network {
//log.info(peer.toString());
}
}
}
return peers;
}

@ -140,7 +140,7 @@ public final class HTTPLoader {
final RequestHeader requestHeader = createRequestheader(request, agent);
// HTTP-Client
final HTTPClient client = new HTTPClient(agent);
try (final HTTPClient client = new HTTPClient(agent)) {
client.setRedirecting(false); // we want to handle redirection
// ourselves, so we don't index pages
// twice
@ -259,6 +259,7 @@ public final class HTTPLoader {
+ "' for URL '" + requestURLString + "'$");
}
}
}
/**
* Extract redirect URL from response header. Status code is supposed to be between 299 and 310. Parameters must not be null.
@ -364,7 +365,7 @@ public final class HTTPLoader {
final RequestHeader requestHeader = createRequestheader(request, agent);
// HTTP-Client
final HTTPClient client = new HTTPClient(agent);
try (final HTTPClient client = new HTTPClient(agent)) {
client.setRedirecting(false); // we want to handle redirection ourselves, so we don't index pages twice
client.setTimout(this.socketTimeout);
client.setHeader(requestHeader.entrySet());
@ -450,6 +451,7 @@ public final class HTTPLoader {
throw new IOException("REJECTED WRONG STATUS TYPE '" + client.getHttpResponse().getStatusLine() + "' for URL '" + requestURLString + "'$");
}
}
}
public static Response load(final Request request, ClientIdentification.Agent agent) throws IOException {
return load(request, agent, 3);
@ -484,7 +486,7 @@ public final class HTTPLoader {
requestHeader.put(HeaderFramework.ACCEPT_CHARSET, DEFAULT_CHARSET);
requestHeader.put(HeaderFramework.ACCEPT_ENCODING, DEFAULT_ENCODING);
final HTTPClient client = new HTTPClient(agent);
try (final HTTPClient client = new HTTPClient(agent)) {
client.setTimout(20000);
client.setHeader(requestHeader.entrySet());
final byte[] responseBody = client.GETbytes(request.url(), null, null, false);
@ -539,6 +541,7 @@ public final class HTTPLoader {
// if the response has not the right response type then reject file
throw new IOException("REJECTED WRONG STATUS TYPE '" + client.getHttpResponse().getStatusLine() + "' for URL " + request.url().toString());
}
}
return response;
}

@ -327,11 +327,11 @@ public class WorkTables extends Tables {
* @return a map of the called urls and the http status code of the api call or -1 if any other IOException occurred
*/
public Map<String, Integer> execAPICalls(String host, int port, Collection<String> pks, final String username, final String pass) {
LinkedHashMap<String, Integer> l = new LinkedHashMap<String, Integer>();
// now call the api URLs and store the result status
final HTTPClient client = new HTTPClient(ClientIdentification.yacyInternetCrawlerAgent);
try (final HTTPClient client = new HTTPClient(ClientIdentification.yacyInternetCrawlerAgent)) {
client.setTimout(120000);
Tables.Row row;
LinkedHashMap<String, Integer> l = new LinkedHashMap<String, Integer>();
for (final String pk: pks) {
row = null;
try {
@ -372,6 +372,9 @@ public class WorkTables extends Tables {
ConcurrentLog.warn("APICALL", "wrong url in apicall " + theapicall);
}
}
} catch (IOException e) {
ConcurrentLog.logException(e);
}
return l;
}
@ -447,11 +450,10 @@ public class WorkTables extends Tables {
*/
public static int execGetAPICall(String host, int port, String path, byte[] pk, final String username, final String pass) {
// now call the api URLs and store the result status
final HTTPClient client = new HTTPClient(ClientIdentification.yacyInternetCrawlerAgent);
client.setTimout(120000);
String url = "http://" + host + ":" + port + path;
if (pk != null) url += "&" + WorkTables.TABLE_API_COL_APICALL_PK + "=" + UTF8.String(pk);
try {
try (final HTTPClient client = new HTTPClient(ClientIdentification.yacyInternetCrawlerAgent)) {
client.setTimout(120000);
client.GETbytes(url, username, pass, false);
return client.getStatusCode();
} catch (final IOException e) {

@ -114,9 +114,8 @@ public class sitemapParser extends AbstractParser implements Parser {
public static SitemapReader parse(final DigestURL sitemapURL, final ClientIdentification.Agent agent) throws IOException {
// download document
ConcurrentLog.info("SitemapReader", "loading sitemap from " + sitemapURL.toNormalform(true));
final HTTPClient client = new HTTPClient(agent);
// client.setHeader(requestHeader.entrySet());
try {
try (final HTTPClient client = new HTTPClient(agent)) {
client.GET(sitemapURL.toNormalform(false), false);
if (client.getStatusCode() != 200) {
throw new IOException("Unable to download the sitemap file " + sitemapURL +

@ -147,19 +147,12 @@ public class opensearchdescriptionReader extends DefaultHandler {
public opensearchdescriptionReader(final String path, final ClientIdentification.Agent agent) {
this();
this.agent = agent;
HTTPClient www = new HTTPClient(agent);
try {
try (HTTPClient www = new HTTPClient(agent)) {
www.GET(path, false);
final SAXParser saxParser = getParser();
saxParser.parse(www.getContentstream(), this);
} catch (final Exception e) {
ConcurrentLog.logException(e);
} finally {
try {
www.close();
} catch (final IOException e) {
ConcurrentLog.logException(e);
}
}
}
@ -170,8 +163,7 @@ public class opensearchdescriptionReader extends DefaultHandler {
this.parsingTextValue = false;
this.rssurl = null;
this.atomurl = null;
HTTPClient www = new HTTPClient(this.agent);
try {
try (HTTPClient www = new HTTPClient(this.agent)) {
www.GET(path, false);
final SAXParser saxParser = getParser();
try {
@ -185,12 +177,6 @@ public class opensearchdescriptionReader extends DefaultHandler {
} catch (final Exception e) {
ConcurrentLog.warn("opensearchdescriptionReader", "parse exception: " + e);
return false;
} finally {
try {
www.close();
} catch (final IOException e) {
ConcurrentLog.logException(e);
}
}
}

@ -132,12 +132,11 @@ public class ProxyHandler extends AbstractRemoteHandler implements Handler {
RequestHeader proxyHeaders = ProxyHandler.convertHeaderFromJetty(request);
setProxyHeaderForClient(request, proxyHeaders);
final HTTPClient client = new HTTPClient(ClientIdentification.yacyProxyAgent);
// send request
try (final HTTPClient client = new HTTPClient(ClientIdentification.yacyProxyAgent)) {
client.setTimout(timeout);
client.setHeader(proxyHeaders.entrySet());
client.setRedirecting(false);
// send request
try {
String queryString = request.getQueryString() != null ? "?" + request.getQueryString() : "";
DigestURL digestURI = new DigestURL(request.getScheme(), request.getServerName(), request.getServerPort(), request.getRequestURI() + queryString);
if (request.getMethod().equals(HeaderFramework.METHOD_GET)) {
@ -219,8 +218,6 @@ public class ProxyHandler extends AbstractRemoteHandler implements Handler {
}
} catch (final SocketException se) {
throw new ServletException("Socket Exception: " + se.getMessage());
} finally {
client.close();
}
// we handled this request, break out of handler chain

@ -159,11 +159,11 @@ public final class Protocol {
final String path,
final Map<String, ContentBody> parts,
final int timeout) throws IOException {
final HTTPClient httpClient = new HTTPClient(ClientIdentification.yacyInternetCrawlerAgent);
try (final HTTPClient httpClient = new HTTPClient(ClientIdentification.yacyInternetCrawlerAgent)) {
httpClient.setTimout(timeout);
MultiProtocolURL targetURL = new MultiProtocolURL(targetBaseURL, path);
this.result = httpClient.POSTbytes(targetURL, Seed.b64Hash2hexHash(targetHash) + ".yacyh", parts, false,
true);
this.result = httpClient.POSTbytes(targetURL, Seed.b64Hash2hexHash(targetHash) + ".yacyh", parts, false, true);
}
}
/**
@ -197,19 +197,16 @@ public final class Protocol {
final String salt = crypt.randomSalt();
long responseTime = Long.MAX_VALUE;
byte[] content = null;
try {
try (final HTTPClient httpClient = new HTTPClient(ClientIdentification.yacyInternetCrawlerAgent, 30000)) {
// generate request
final Map<String, ContentBody> parts =
basicRequestParts(Switchboard.getSwitchboard(), null, salt);
final Map<String, ContentBody> parts = basicRequestParts(Switchboard.getSwitchboard(), null, salt);
parts.put("count", UTF8.StringBody("20"));
parts.put("magic", UTF8.StringBody(Long.toString(Network.magic)));
parts.put("seed", UTF8.StringBody(mySeed.genSeedStr(salt)));
// send request
final long start = System.currentTimeMillis();
// final byte[] content = HTTPConnector.getConnector(MultiProtocolURI.yacybotUserAgent).post(new MultiProtocolURI("http://" + address + "/yacy/hello.html"), 30000, yacySeed.b64Hash2hexHash(otherHash) + ".yacyh", parts);
final HTTPClient httpClient = new HTTPClient(ClientIdentification.yacyInternetCrawlerAgent, 30000);
content =
httpClient.POSTbytes(
content = httpClient.POSTbytes(
new MultiProtocolURL(targetBaseURL, "/yacy/hello.html"),
Seed.b64Hash2hexHash(targetHash) + ".yacyh",
parts,
@ -433,8 +430,8 @@ public final class Protocol {
parts.put("count", UTF8.StringBody(Integer.toString(maxCount)));
parts.put("time", UTF8.StringBody(Long.toString(maxTime)));
// final byte[] result = HTTPConnector.getConnector(MultiProtocolURI.yacybotUserAgent).post(new MultiProtocolURI("http://" + target.getClusterAddress() + "/yacy/urls.xml"), (int) maxTime, target.getHexHash() + ".yacyh", parts);
final HTTPClient httpClient = new HTTPClient(ClientIdentification.yacyInternetCrawlerAgent, (int) maxTime);
RSSReader reader = null;
try (final HTTPClient httpClient = new HTTPClient(ClientIdentification.yacyInternetCrawlerAgent, (int) maxTime)) {
for (final String ip: target.getIPs()) {
MultiProtocolURL targetBaseURL = null;
try {
@ -469,6 +466,9 @@ public final class Protocol {
target.put(Seed.RCOUNT, "0");
seedDB.peerActions.interfaceDeparture(target, ip);
}
} catch (IOException e) {
Network.log.warn(e);
}
final RSSFeed feed = reader == null ? null : reader.getFeed();
if ( feed == null ) {
@ -962,13 +962,14 @@ public final class Protocol {
//resultMap = FileUtils.table(HTTPConnector.getConnector(MultiProtocolURI.crawlerUserAgent).post(new MultiProtocolURI("http://" + target.getClusterAddress() + "/yacy/search.html"), 60000, target.getHexHash() + ".yacyh", parts));
}
final HTTPClient httpClient = new HTTPClient(ClientIdentification.yacyInternetCrawlerAgent, 8000);
try (final HTTPClient httpClient = new HTTPClient(ClientIdentification.yacyInternetCrawlerAgent, 8000)) {
byte[] a = httpClient.POSTbytes(new MultiProtocolURL(targetBaseURL + "/yacy/search.html"), hostname, parts, false, true);
if (a != null && a.length > 200000) {
// there is something wrong. This is too large, maybe a hack on the other side?
a = null;
}
resultMap = FileUtils.table(a);
}
// evaluate request result
if ( resultMap == null || resultMap.isEmpty() ) {
@ -1628,9 +1629,9 @@ public final class Protocol {
}
parts.put("lurlEntry", UTF8.StringBody(crypt.simpleEncode(lurlstr, salt)));
// send request
final HTTPClient httpClient = new HTTPClient(ClientIdentification.yacyInternetCrawlerAgent, 10000);
MultiProtocolURL targetBaseURL = target.getPublicMultiprotocolURL(ip, preferHttps);
byte[] content;
try (final HTTPClient httpClient = new HTTPClient(ClientIdentification.yacyInternetCrawlerAgent, 10000)) {
MultiProtocolURL targetBaseURL = target.getPublicMultiprotocolURL(ip, preferHttps);
try {
content = httpClient.POSTbytes(new MultiProtocolURL(targetBaseURL, "/yacy/crawlReceipt.html"),
target.getHexHash() + ".yacyh", parts, false, true);
@ -1648,6 +1649,7 @@ public final class Protocol {
throw e;
}
}
}
return FileUtils.table(content);
} catch (final Exception e ) {
// most probably a network time-out exception
@ -1849,8 +1851,8 @@ public final class Protocol {
parts.put("wordc", UTF8.StringBody(Integer.toString(indexes.size())));
parts.put("entryc", UTF8.StringBody(Integer.toString(indexcount)));
parts.put("indexes", UTF8.StringBody(entrypost.toString()));
final HTTPClient httpClient = new HTTPClient(ClientIdentification.yacyInternetCrawlerAgent, timeout);
byte[] content = null;
try (final HTTPClient httpClient = new HTTPClient(ClientIdentification.yacyInternetCrawlerAgent, timeout)) {
try {
content = httpClient.POSTbytes(new MultiProtocolURL(targetBaseURL, "/yacy/transferRWI.html"),
targetSeed.getHexHash() + ".yacyh", parts, gzipBody, true);
@ -1868,6 +1870,7 @@ public final class Protocol {
throw e;
}
}
}
final Iterator<String> v = FileUtils.strings(content);
// this should return a list of urlhashes that are unknown
@ -1953,8 +1956,8 @@ public final class Protocol {
MultiProtocolURL targetBaseURL = targetSeed.getPublicMultiprotocolURL(ip, preferHttps);
parts.put("urlc", UTF8.StringBody(Integer.toString(urlc)));
final HTTPClient httpClient = new HTTPClient(ClientIdentification.yacyInternetCrawlerAgent, timeout);
byte[] content = null;
try (final HTTPClient httpClient = new HTTPClient(ClientIdentification.yacyInternetCrawlerAgent, timeout)) {
try {
content = httpClient.POSTbytes(new MultiProtocolURL(targetBaseURL, "/yacy/transferURL.html"),
targetSeed.getHexHash() + ".yacyh", parts, gzipBody, true);
@ -1968,6 +1971,7 @@ public final class Protocol {
throw e;
}
}
}
final Iterator<String> v = FileUtils.strings(content);
final Map<String, String> result = FileUtils.table(v);
@ -1998,10 +2002,8 @@ public final class Protocol {
SwitchboardConstants.NETWORK_PROTOCOL_HTTPS_PREFERRED_DEFAULT);
for (final String ip : targetSeed.getIPs()) {
try {
final Map<String, ContentBody> parts =
basicRequestParts(sb, targetSeed.hash, salt);
final HTTPClient httpclient = new HTTPClient(ClientIdentification.yacyInternetCrawlerAgent, 15000);
try (final HTTPClient httpclient = new HTTPClient(ClientIdentification.yacyInternetCrawlerAgent, 15000)) {
final Map<String, ContentBody> parts = basicRequestParts(sb, targetSeed.hash, salt);
MultiProtocolURL targetBaseURL = targetSeed.getPublicMultiprotocolURL(ip, preferHttps);
byte[] content;
try {

@ -897,9 +897,9 @@ public final class SeedDB implements AlternativeDomainNames {
reqHeader.put(HeaderFramework.CACHE_CONTROL, "no-cache, no-store"); // httpc uses HTTP/1.0 is this necessary?
reqHeader.put(HeaderFramework.USER_AGENT, ClientIdentification.yacyInternetCrawlerAgent.userAgent);
final HTTPClient client = new HTTPClient(ClientIdentification.yacyInternetCrawlerAgent);
client.setHeader(reqHeader.entrySet());
byte[] content = null;
try (final HTTPClient client = new HTTPClient(ClientIdentification.yacyInternetCrawlerAgent)) {
client.setHeader(reqHeader.entrySet());
try {
// send request
content = client.GETbytes(seedURL, null, null, false);
@ -911,6 +911,7 @@ public final class SeedDB implements AlternativeDomainNames {
if (client.getHttpResponse().getStatusLine().getStatusCode() != 200) {
throw new IOException("Server returned status: " + client.getHttpResponse().getStatusLine());
}
}
try {
// uncompress it if it is gzipped
@ -1124,13 +1125,12 @@ public final class SeedDB implements AlternativeDomainNames {
@Override
public void run() {
// load the seed list
try {
try (final HTTPClient client = new HTTPClient(ClientIdentification.yacyInternetCrawlerAgent, timeout)) {
DigestURL url = new DigestURL(seedListFileURL);
//final long start = System.currentTimeMillis();
final RequestHeader reqHeader = new RequestHeader();
reqHeader.put(HeaderFramework.PRAGMA, "no-cache");
reqHeader.put(HeaderFramework.CACHE_CONTROL, "no-cache, no-store");
final HTTPClient client = new HTTPClient(ClientIdentification.yacyInternetCrawlerAgent, timeout);
client.setHeader(reqHeader.entrySet());
client.HEADResponse(url.toNormalform(false), false);

@ -444,10 +444,10 @@ public final class HTTPDProxyHandler {
requestHeader.remove(HeaderFramework.HOST);
final HTTPClient client = setupHttpClient(requestHeader, agent);
// send request
try {
try (final HTTPClient client = new HTTPClient(agent, timeout)) {
client.setHeader(requestHeader.entrySet());
client.setRedirecting(false);
client.GET(getUrl, false);
if (log.isFinest()) log.finest(reqID +" response status: "+ client.getHttpResponse().getStatusLine());
@ -596,20 +596,7 @@ public final class HTTPDProxyHandler {
}
} // end hasBody
} catch(final SocketException se) {
// if opened ...
// if(res != null) {
// // client cut proxy connection, abort download
// res.abort();
// }
client.close();
handleProxyException(se,conProp,respond,url);
} finally {
// if opened ...
// if(res != null) {
// // ... close connection
// res.closeStream();
// }
client.close();
}
} catch (final Exception e) {
handleProxyException(e,conProp,respond,url);
@ -759,20 +746,6 @@ public final class HTTPDProxyHandler {
return domain;
}
/**
* creates a new HttpClient and sets parameters according to proxy needs
*
* @param requestHeader
* @return
*/
private static HTTPClient setupHttpClient(final RequestHeader requestHeader, final ClientIdentification.Agent agent) {
// setup HTTP-client
final HTTPClient client = new HTTPClient(agent, timeout);
client.setHeader(requestHeader.entrySet());
client.setRedirecting(false);
return client;
}
/**
* determines in which form the response should be send and sets header accordingly
* if the content length is not set we need to use chunked content encoding

@ -686,23 +686,13 @@ public class serverSwitch {
final String[] uris = CommonPattern.COMMA.split(uri);
for (String netdef : uris) {
netdef = netdef.trim();
try {
try (final HTTPClient client = new HTTPClient(ClientIdentification.yacyInternetCrawlerAgent)) {
final RequestHeader reqHeader = new RequestHeader();
reqHeader
.put(HeaderFramework.USER_AGENT,
ClientIdentification.yacyInternetCrawlerAgent.userAgent);
final HTTPClient client = new HTTPClient(
ClientIdentification.yacyInternetCrawlerAgent);
reqHeader.put(HeaderFramework.USER_AGENT, ClientIdentification.yacyInternetCrawlerAgent.userAgent);
client.setHeader(reqHeader.entrySet());
byte[] data = client
.GETbytes(
uri,
getConfig(
SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME,
"admin"),
getConfig(
SwitchboardConstants.ADMIN_ACCOUNT_B64MD5,
""), false);
byte[] data = client.GETbytes(uri,
getConfig(SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME, "admin"),
getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, ""), false);
if (data == null || data.length == 0) {
continue;
}

@ -532,9 +532,7 @@ public final class yacy {
final String adminUser = config.getProperty(SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME, "admin");
// send 'wget' to web interface
final HTTPClient con = new HTTPClient(ClientIdentification.yacyInternetCrawlerAgent);
// con.setHeader(requestHeader.entrySet());
try {
try (final HTTPClient con = new HTTPClient(ClientIdentification.yacyInternetCrawlerAgent)) {
/* First get a valid transaction token using HTTP GET */
con.GETbytes("http://localhost:"+ port +"/" + path, adminUser, encodedPassword, false);
@ -600,9 +598,7 @@ public final class yacy {
if (encodedPassword == null) encodedPassword = ""; // not defined
// send 'wget' to web interface
final HTTPClient con = new HTTPClient(ClientIdentification.yacyInternetCrawlerAgent);
// con.setHeader(requestHeader.entrySet());
try {
try (final HTTPClient con = new HTTPClient(ClientIdentification.yacyInternetCrawlerAgent)) {
con.GETbytes("http://localhost:"+ port +"/" + path, config.getProperty(SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME,"admin"), encodedPassword, false);
if (con.getStatusCode() > 199 && con.getStatusCode() < 300) {
ConcurrentLog.config("COMMAND-STEERING", "YACY accepted steering command: " + processdescription);

Loading…
Cancel
Save