removed non-working realm setting in http client (auth for localhost was

added in previous commit)
pull/1/head
Michael Peter Christen 11 years ago
parent 9d52b337f3
commit 2939b47986

@ -215,7 +215,6 @@ public class CrawlStartScanner_p
WorkTables.execAPICall(
Domains.LOCALHOST,
(int) sb.getConfigLong("port", 8090),
sb.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, ""),
path,
pk);
}
@ -261,7 +260,6 @@ public class CrawlStartScanner_p
WorkTables.execAPICall(
Domains.LOCALHOST,
(int) sb.getConfigLong("port", 8090),
sb.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, ""),
path,
u.hash());
}

@ -206,7 +206,7 @@ public class Table_API_p {
}
// now call the api URLs and store the result status
final Map<String, Integer> l = sb.tables.execAPICalls(Domains.LOCALHOST, (int) sb.getConfigLong("port", 8090), sb.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, ""), pks);
final Map<String, Integer> l = sb.tables.execAPICalls(Domains.LOCALHOST, (int) sb.getConfigLong("port", 8090), pks);
// construct result table
prop.put("showexec", l.isEmpty() ? 0 : 1);

@ -49,7 +49,6 @@ import net.yacy.cora.protocol.ClientIdentification;
import net.yacy.cora.protocol.ConnectionInfo;
import net.yacy.cora.protocol.Domains;
import net.yacy.cora.protocol.HeaderFramework;
import net.yacy.cora.protocol.RequestHeader;
import net.yacy.search.Switchboard;
import net.yacy.search.SwitchboardConstants;
@ -112,7 +111,6 @@ public class HTTPClient {
private HttpUriRequest currentRequest = null;
private long upbytes = 0L;
private String host = null;
private String realm = null;
public HTTPClient(final ClientIdentification.Agent agent) {
@ -304,15 +302,6 @@ public class HTTPClient {
reqConfBuilder.setRelativeRedirectsAllowed(redirecting);
}
/**
* This method sets the authorization realm for the request
*
* @param realm
*/
public void setRealm(final String realm) {
this.realm = realm;
}
/**
* This method GETs a page from the server.
*
@ -708,10 +697,7 @@ public class HTTPClient {
httpUriRequest.setHeader(entry.getKey(),entry.getValue());
}
}
if (this.host != null)
httpUriRequest.setHeader(HTTP.TARGET_HOST, this.host);
if (this.realm != null)
httpUriRequest.setHeader(RequestHeader.AUTHORIZATION, "Basic " + this.realm);
if (this.host != null) httpUriRequest.setHeader(HTTP.TARGET_HOST, this.host);
httpUriRequest.setHeader("Connection", "close"); // don't keep alive, prevent CLOSE_WAIT state
}

@ -218,10 +218,9 @@ public class WorkTables extends Tables {
* @param realm authentification realm
* @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, String realm, Collection<String> pks) {
public Map<String, Integer> execAPICalls(String host, int port, Collection<String> pks) {
// now call the api URLs and store the result status
final HTTPClient client = new HTTPClient(ClientIdentification.yacyInternetCrawlerAgent);
client.setRealm(realm);
client.setTimout(120000);
Tables.Row row;
String url;
@ -250,10 +249,9 @@ public class WorkTables extends Tables {
return l;
}
public static int execAPICall(String host, int port, String realm, String path, byte[] pk) {
public static int execAPICall(String host, int port, String path, byte[] pk) {
// now call the api URLs and store the result status
final HTTPClient client = new HTTPClient(ClientIdentification.yacyInternetCrawlerAgent);
client.setRealm(realm);
client.setTimout(120000);
String url = "http://" + host + ":" + port + path;
if (pk != null) url += "&" + WorkTables.TABLE_API_COL_APICALL_PK + "=" + UTF8.String(pk);
@ -274,10 +272,10 @@ public class WorkTables extends Tables {
* @param realm authentification realm
* @return the http status code of the api call or -1 if any other IOException occurred
*/
public int execAPICall(String pk, String host, int port, String realm) {
public int execAPICall(String pk, String host, int port) {
ArrayList<String> pks = new ArrayList<String>();
pks.add(pk);
Map<String, Integer> m = execAPICalls(host, port, realm, pks);
Map<String, Integer> m = execAPICalls(host, port, pks);
if (m.isEmpty()) return -1;
return m.values().iterator().next().intValue();
}

@ -110,8 +110,8 @@ public class YMarkCrawlStart extends HashMap<String,String>{
}
}
public int exec(final String host, final int port, final String realm) {
return this.worktables.execAPICall(this.apicall_pk, host, port, realm);
public int exec(final String host, final int port) {
return this.worktables.execAPICall(this.apicall_pk, host, port);
}
private void load() {

@ -2457,7 +2457,7 @@ public final class Switchboard extends serverSwitch {
startupAction = false;
// execute api calls
final Map<String, Integer> callResult = this.tables.execAPICalls("localhost", (int) getConfigLong("port", 8090), getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, ""), pks);
final Map<String, Integer> callResult = this.tables.execAPICalls("localhost", (int) getConfigLong("port", 8090), pks);
for ( final Map.Entry<String, Integer> call : callResult.entrySet() ) {
this.log.info("Scheduler executed api call, response " + call.getValue() + ": " + call.getKey());
}

Loading…
Cancel
Save