Skip to content

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

- remove empty http0_9 status text array and unused default_charset = ISO-8859-1

reger79e79474425c
diff --git a/source/net/yacy/cora/protocol/HeaderFramework.java b/source/net/yacy/cora/protocol/HeaderFramework.java
index f26f9dbe3..69be76646 100644
--- a/source/net/yacy/cora/protocol/HeaderFramework.java
+++ b/source/net/yacy/cora/protocol/HeaderFramework.java
@@ -62,8 +62,6 @@ public class HeaderFramework extends TreeMap<String, String> implements Map<Stri
private static final long serialVersionUID = 18L;
- static final String DEFAULT_CHARSET = "ISO-8859-1";
-
/* =============================================================
* Constants defining http versions
* ============================================================= */
@@ -144,10 +142,8 @@ public class HeaderFramework extends TreeMap<String, String> implements Map<Stri
/* =============================================================
* defining default http status messages
* ============================================================= */
- public static final Map<String, String> http0_9 = new ConcurrentHashMap<String, String>();
public static final Map<String, String> http1_0 = new ConcurrentHashMap<String, String>();
static {
- http1_0.putAll(http0_9);
http1_0.put("200","OK");
http1_0.put("201","Created");
http1_0.put("202","Accepted");
@@ -538,9 +534,8 @@ public class HeaderFramework extends TreeMap<String, String> implements Map<Stri
// setting the status text if it was not already set
if ((httpStatusText == null)||(httpStatusText.length()==0)) {
- if (httpVersion.equals("HTTP/1.0") && HeaderFramework.http1_0.containsKey(Integer.toString(httpStatusCode)))
- httpStatusText = HeaderFramework.http1_0.get(Integer.toString(httpStatusCode));
- else if (httpVersion.equals("HTTP/1.1") && HeaderFramework.http1_1.containsKey(Integer.toString(httpStatusCode)))
+ // http1_1 contains all status code text
+ if (HeaderFramework.http1_1.containsKey(Integer.toString(httpStatusCode)))
httpStatusText = HeaderFramework.http1_1.get(Integer.toString(httpStatusCode));
else httpStatusText = "Unknown";
}
diff --git a/source/net/yacy/cora/protocol/ResponseHeader.java b/source/net/yacy/cora/protocol/ResponseHeader.java
index c531a334c..6f9d29fa7 100644
--- a/source/net/yacy/cora/protocol/ResponseHeader.java
+++ b/source/net/yacy/cora/protocol/ResponseHeader.java
@@ -20,15 +20,10 @@
package net.yacy.cora.protocol;
-import java.nio.charset.Charset;
-import java.nio.charset.IllegalCharsetNameException;
-import java.nio.charset.UnsupportedCharsetException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
-import net.yacy.cora.util.ConcurrentLog;
-
import org.apache.http.Header;
public class ResponseHeader extends HeaderFramework {
@@ -36,7 +31,6 @@ public class ResponseHeader extends HeaderFramework {
// response header properties
private static final long serialVersionUID = 0L;
- private static final ConcurrentLog log = new ConcurrentLog(ResponseHeader.class.getName());
private Date date_cache_Date = null;
private Date date_cache_Expires = null;
@@ -108,69 +102,6 @@ public class ResponseHeader extends HeaderFramework {
((get(HeaderFramework.CONTENT_ENCODING)).toUpperCase().startsWith("GZIP")));
}
- public static Object[] parseResponseLine(final String respLine) {
-
- if ((respLine == null) || (respLine.isEmpty())) {
- return new Object[]{"HTTP/1.0",Integer.valueOf(500),"status line parse error"};
- }
-
- int p = respLine.indexOf(' ',0);
- if (p < 0) {
- return new Object[]{"HTTP/1.0",Integer.valueOf(500),"status line parse error"};
- }
-
- String httpVer, status, statusText;
- Integer statusCode;
-
- // the http version reported by the server
- httpVer = respLine.substring(0,p);
-
- // Status of the request, e.g. "200 OK"
- status = respLine.substring(p + 1).trim(); // the status code plus reason-phrase
-
- // splitting the status into statuscode and statustext
- p = status.indexOf(' ',0);
- try {
- statusCode = Integer.valueOf((p < 0) ? status.trim() : status.substring(0,p).trim());
- statusText = (p < 0) ? "" : status.substring(p+1).trim();
- } catch (final Exception e) {
- statusCode = Integer.valueOf(500);
- statusText = status;
- }
-
- return new Object[]{httpVer,statusCode,statusText};
- }
-
-
- /**
- * @param header
- * @return a supported Charset, so data can be encoded (may not be correct)
- */
- public Charset getCharSet() {
- String charSetName = getCharacterEncoding();
- if (charSetName == null) {
- // no character encoding is sent by the server
- charSetName = DEFAULT_CHARSET;
- }
- // maybe the charset is valid but not installed on this computer
- try {
- if(!Charset.isSupported(charSetName)) {
- log.warn("charset '"+ charSetName +"' is not supported on this machine, using default ("+ Charset.defaultCharset().name() +")");
- // use system default
- return Charset.defaultCharset();
- }
- } catch(final IllegalCharsetNameException e) {
- log.warn("Charset in header is illegal: '"+ charSetName +"'\n "+ toString() + "\n" + e.getMessage());
- // use system default
- return Charset.defaultCharset();
- } catch (final UnsupportedCharsetException e) {
- log.warn("Charset in header is unsupported: '"+ charSetName +"'\n "+ toString() + "\n" + e.getMessage());
- // use system default
- return Charset.defaultCharset();
- }
- return Charset.forName(charSetName);
- }
-
public String getXRobotsTag() {
String x_robots_tag = this.get(HeaderFramework.X_ROBOTS_TAG, "");
if (x_robots_tag.isEmpty()) {
diff --git a/source/net/yacy/server/http/HTTPDemon.java b/source/net/yacy/server/http/HTTPDemon.java
index 365402ea3..d2b606aa8 100644
--- a/source/net/yacy/server/http/HTTPDemon.java
+++ b/source/net/yacy/server/http/HTTPDemon.java
@@ -132,9 +132,8 @@ public final class HTTPDemon {
// setting the proper http status message
String httpVersion = (String) conProp.get(HeaderFramework.CONNECTION_PROP_HTTP_VER); if (httpVersion == null) httpVersion = "HTTP/1.1";
if ((httpStatusText == null)||(httpStatusText.length()==0)) {
- if (httpVersion.equals("HTTP/1.0") && HeaderFramework.http1_0.containsKey(Integer.toString(httpStatusCode)))
- httpStatusText = HeaderFramework.http1_0.get(Integer.toString(httpStatusCode));
- else if (httpVersion.equals("HTTP/1.1") && HeaderFramework.http1_1.containsKey(Integer.toString(httpStatusCode)))
+ //http1_1 includes http1_0 messages
+ if (HeaderFramework.http1_1.containsKey(Integer.toString(httpStatusCode)))
httpStatusText = HeaderFramework.http1_1.get(Integer.toString(httpStatusCode));
else httpStatusText = "Unknown";
}
@@ -276,9 +275,8 @@ public final class HTTPDemon {
try {
if ((httpStatusText == null)||(httpStatusText.length()==0)) {
- if (httpVersion.equals(HeaderFramework.HTTP_VERSION_1_0) && HeaderFramework.http1_0.containsKey(Integer.toString(httpStatusCode)))
- httpStatusText = HeaderFramework.http1_0.get(Integer.toString(httpStatusCode));
- else if (httpVersion.equals(HeaderFramework.HTTP_VERSION_1_1) && HeaderFramework.http1_1.containsKey(Integer.toString(httpStatusCode)))
+ if (HeaderFramework.http1_1.containsKey(Integer.toString(httpStatusCode)))
+ //http1_1 includes http1_0 messages
httpStatusText = HeaderFramework.http1_1.get(Integer.toString(httpStatusCode));
else httpStatusText = "Unknown";
}