Skip to content

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

fix small bug introduced in r4089 that appeared when we tried to remove "gzip" encoding from Accept-Encodings header closes http://forum.yacy-websuche.de/viewtopic.php?f=6&t=336

fuchsie192f9913442
diff --git a/source/de/anomic/http/httpc.java b/source/de/anomic/http/httpc.java
index 0e26cf386..ea9b71ad4 100644
--- a/source/de/anomic/http/httpc.java
+++ b/source/de/anomic/http/httpc.java
@@ -666,7 +666,10 @@ 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 + 5));
+ // ex: "gzip,deflate" => pos == 0, but we need to remove the "," as well => substring(pos+5),
+ // ex: "gzip" => pos == 0, but substring(pos+5) would exceed boundaries
+ String enc = encoding.substring(0, pos) + (encoding.length() > (pos+5) ? encoding.substring(pos + 5) : "");
+ header.put(httpHeader.ACCEPT_ENCODING, enc);
}
}
} else {