Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

Fix problems with some web servers which couldn't handle the way yacy was sending requests. Thx to celle for the patch. http://forum.yacy-websuche.de/viewtopic.php?f=5&t=320

fuchsiae4b9308efe9
diff --git a/source/de/anomic/http/httpc.java b/source/de/anomic/http/httpc.java
index bad06b831..0e26cf386 100644
--- a/source/de/anomic/http/httpc.java
+++ b/source/de/anomic/http/httpc.java
@@ -666,7 +666,7 @@ public final class httpc {
if (pos >= 0) {
// remove the gzip encoding
//System.out.println("!!! removing gzip encoding");
- header.put(httpHeader.ACCEPT_ENCODING, encoding.substring(0, pos) + encoding.substring(pos + 4));
+ header.put(httpHeader.ACCEPT_ENCODING, encoding.substring(0, pos) + encoding.substring(pos + 5));
}
}
} else {
@@ -675,10 +675,11 @@ public final class httpc {
//header = new httpHeader(); header.put("Host", this.host); // debug
+ StringBuffer sb = new StringBuffer();
// send request
if ((this.remoteProxyUse) && (!(method.equals(httpHeader.METHOD_CONNECT))))
path = ((this.adressed_port == 443) ? "https://" : "http://") + this.adressed_host + ":" + this.adressed_port + path;
- serverCore.send(this.clientOutput, method + " " + path + " HTTP/1.0"); // if set to HTTP/1.1, servers give time-outs?
+ sb.append(method + " " + path + " HTTP/1.0" + serverCore.crlfString); // TODO if set to HTTP/1.1, servers give time-outs?
// send header
//System.out.println("***HEADER for path " + path + ": PROXY TO SERVER = " + header.toString()); // DEBUG
@@ -692,14 +693,15 @@ public final class httpc {
if ((tag != '*') && (tag != '#')) {
count = header.keyCount(key);
for (int j = 0; j < count; j++) {
- serverCore.send(this.clientOutput, key + ": " + ((String) header.getSingle(key, j)).trim());
+ sb.append(key + ": " + ((String) header.getSingle(key, j)).trim() + serverCore.crlfString);
}
//System.out.println("#" + key + ": " + value);
}
}
- // send terminating line
- serverCore.send(this.clientOutput, "");
+ // add terminating line
+ sb.append(serverCore.crlfString);
+ serverCore.send(this.clientOutput, sb.toString());
this.clientOutput.flush();
// this is the place where www.stern.de refuses to answer ..???
diff --git a/source/de/anomic/server/serverCore.java b/source/de/anomic/server/serverCore.java
index 21b435a75..37084a213 100644
--- a/source/de/anomic/server/serverCore.java
+++ b/source/de/anomic/server/serverCore.java
@@ -859,7 +859,7 @@ public final class serverCore extends serverAbstractThread implements serverThre
}
public void writeLine(String messg) throws IOException {
- send(this.out, messg);
+ send(this.out, messg + crlfString);
log(true, messg);
}
@@ -1205,7 +1205,8 @@ public final class serverCore extends serverAbstractThread implements serverThre
public static void send(OutputStream os, String buf) throws IOException {
os.write(buf.getBytes());
- os.write(crlf);
+ // TODO make sure there was no reason to add this additional newline
+ //os.write(crlf);
os.flush();
}