Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@3033 6c8d7289-2bf4-0310-a012-ef5d649a1542
  • Loading branch information
orbiter committed Dec 1, 2006
1 parent 29a0fd0 commit fb7902a
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 33 deletions.
20 changes: 10 additions & 10 deletions source/de/anomic/http/httpc.java
Expand Up @@ -1433,7 +1433,7 @@ public static httpHeader whead(
}
}

public static ArrayList wput(
public static byte[] wput(
URL url,
String vhost,
int timeout,
Expand All @@ -1455,16 +1455,16 @@ public static ArrayList wput(
files
);

if (a == null) return null;

// support of gzipped data
a = serverFileUtils.uncompressGZipArray(a);

// return result
return a;

//System.out.println("wput-out=" + new String(a));
int s = 0;
int e;
ArrayList v = new ArrayList();
while (s < a.length) {
e = s; while (e < a.length) if (a[e++] < 32) {e--; break;}
v.add(new String(a, s, e - s));
s = e; while (s < a.length) if (a[s++] >= 32) {s--; break;}
}
return v;
//return nxTools.strings(a);
}

public static void main(String[] args) {
Expand Down
2 changes: 2 additions & 0 deletions source/de/anomic/tools/nxTools.java
Expand Up @@ -72,6 +72,7 @@ public static HashMap table(byte[] a, String encoding) {
}

public static HashMap table(ArrayList list) {
if (list == null) return new HashMap();
Iterator i = list.iterator();
int pos;
String line;
Expand Down Expand Up @@ -154,6 +155,7 @@ public static ArrayList strings(byte[] a) {
}

public static ArrayList strings(byte[] a, String encoding) {
if (a == null) return new ArrayList();
int s = 0;
int e;
ArrayList v = new ArrayList();
Expand Down
45 changes: 22 additions & 23 deletions source/de/anomic/yacy/yacyClient.java
Expand Up @@ -140,7 +140,7 @@ public static int publishMySeed(String address, String otherHash) {
(useProxy)?yacyCore.seedDB.sb.remoteProxyConfig:null,
obj,
null
)
), "UTF-8"
);
} catch (Exception e) {
if (Thread.currentThread().isInterrupted()) {
Expand Down Expand Up @@ -457,7 +457,7 @@ public static String[] search(
(useProxy)?yacyCore.seedDB.sb.remoteProxyConfig:null,
obj,
null
)
), "UTF-8"
);
} catch (IOException e) {
yacyCore.log.logFine("SEARCH failed FROM " + targetPeer.hash + ":" + targetPeer.getName() + " (" + e.getMessage() + "), score=" + targetPeer.selectscore + ", DHTdist=" + yacyDHTAction.dhtDistance(targetPeer.hash, wordhashes));
Expand Down Expand Up @@ -636,7 +636,7 @@ public static HashMap permissionMessage(String targetHash) {
(useProxy)?yacyCore.seedDB.sb.remoteProxyConfig:null,
post,
null
)
), "UTF-8"
);
} catch (Exception e) {
// most probably a network time-out exception
Expand Down Expand Up @@ -672,7 +672,8 @@ public static HashMap postMessage(String targetHash, String subject, byte[] mess

// sending request
try {
final ArrayList v = httpc.wput(
return nxTools.table(
httpc.wput(
new URL("http://" + address + "/yacy/message.html"),
yacySeed.b64Hash2hexHash(targetHash) + ".yacyh",
20000,
Expand All @@ -681,9 +682,7 @@ public static HashMap postMessage(String targetHash, String subject, byte[] mess
(useProxy)?yacyCore.seedDB.sb.remoteProxyConfig:null,
post,
null
);

return nxTools.table(v);
), "UTF-8");
} catch (Exception e) {
yacyCore.log.logSevere("yacyClient.postMessage error:" + e.getMessage());
return null;
Expand Down Expand Up @@ -736,7 +735,7 @@ public static HashMap transferPermission(String targetAddress, long filesize, St
(useProxy)?yacyCore.seedDB.sb.remoteProxyConfig:null,
post,
null
)
), "UTF-8"
);
} catch (Exception e) {
// most probably a network time-out exception
Expand Down Expand Up @@ -769,7 +768,8 @@ public static HashMap transferStore(String targetAddress, String access, String
// sending request
try {
final URL url = new URL("http://" + targetAddress + "/yacy/transfer.html");
final ArrayList v = httpc.wput(
return nxTools.table(
httpc.wput(
url,
url.getHost(), // yacyCore.seedDB.mySeed.getHexHash() + ".yacyh",
20000,
Expand All @@ -778,9 +778,7 @@ public static HashMap transferStore(String targetAddress, String access, String
(useProxy)?yacyCore.seedDB.sb.remoteProxyConfig:null,
post,
files
);

return nxTools.table(v);
), "UTF-8");
} catch (Exception e) {
yacyCore.log.logSevere("yacyClient.postMessage error:" + e.getMessage());
return null;
Expand Down Expand Up @@ -863,7 +861,7 @@ public static HashMap crawlOrder(yacySeed targetSeed, URL[] url, URL[] referrer,
(useProxy)?yacyCore.seedDB.sb.remoteProxyConfig:null,
post,
null
)
), "UTF-8"
);
} catch (Exception e) {
// most probably a network time-out exception
Expand Down Expand Up @@ -1084,7 +1082,8 @@ private static HashMap transferRWI(yacySeed targetSeed, indexContainer[] indexes
post.put("entryc", Integer.toString(indexcount));
post.put("indexes", entrypost.toString());
try {
final ArrayList v = httpc.wput(
final ArrayList v = nxTools.strings(
httpc.wput(
new URL("http://" + address + "/yacy/transferRWI.html"),
targetSeed.getHexHash() + ".yacyh",
timeout,
Expand All @@ -1093,9 +1092,9 @@ private static HashMap transferRWI(yacySeed targetSeed, indexContainer[] indexes
(useProxy)?yacyCore.seedDB.sb.remoteProxyConfig:null,
post,
null
);
), "UTF-8");
// this should return a list of urlhashes that are unknwon
if (v != null) {
if ((v != null) && (v.size() > 0)) {
yacyCore.seedDB.mySeed.incSI(indexcount);
}

Expand Down Expand Up @@ -1146,7 +1145,8 @@ private static HashMap transferURL(yacySeed targetSeed, indexURLEntry[] urls, bo
}
post.put("urlc", Integer.toString(urlc));
try {
final ArrayList v = httpc.wput(
final ArrayList v = nxTools.strings(
httpc.wput(
new URL("http://" + address + "/yacy/transferURL.html"),
targetSeed.getHexHash() + ".yacyh",
timeout,
Expand All @@ -1155,9 +1155,9 @@ private static HashMap transferURL(yacySeed targetSeed, indexURLEntry[] urls, bo
(useProxy)?yacyCore.seedDB.sb.remoteProxyConfig:null,
post,
null
);
), "UTF-8");

if (v != null) {
if ((v != null) && (v.size() > 0)) {
yacyCore.seedDB.mySeed.incSU(urlc);
}

Expand Down Expand Up @@ -1185,7 +1185,8 @@ public static HashMap getProfile(yacySeed targetSeed) {
String address = targetSeed.getAddress();
if (address == null) { address = "localhost:8080"; }
try {
final ArrayList v = httpc.wput(
return nxTools.table(
httpc.wput(
new URL("http://" + address + "/yacy/profile.html"),
targetSeed.getHexHash() + ".yacyh",
10000,
Expand All @@ -1194,9 +1195,7 @@ public static HashMap getProfile(yacySeed targetSeed) {
(useProxy)?yacyCore.seedDB.sb.remoteProxyConfig:null,
post,
null
);

return nxTools.table(v);
), "UTF-8");
} catch (Exception e) {
yacyCore.log.logSevere("yacyClient.getProfile error:" + e.getMessage());
return null;
Expand Down

0 comments on commit fb7902a

Please sign in to comment.