Skip to content

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

Improve compliance to rfc *) There is no status line in HTTP/0.9 *) Answers to HEAD requests should return the same headers as a GET request

hermense974d0cb99bc
diff --git a/source/de/anomic/http/httpd.java b/source/de/anomic/http/httpd.java
index 74d996076..7de49efee 100644
--- a/source/de/anomic/http/httpd.java
+++ b/source/de/anomic/http/httpd.java
@@ -1275,13 +1275,13 @@ public final class httpd implements serverHandler {
StringBuffer headerStringBuffer = new StringBuffer(560);
- // write status line
- headerStringBuffer.append(httpVersion).append(" ")
- .append(Integer.toString(httpStatusCode)).append(" ")
- .append(httpStatusText).append("\r\n");
-
- // "HTTP/0.9" does not have a header in the response
+ // "HTTP/0.9" does not have a status line or header in the response
if (! httpVersion.toUpperCase().equals("HTTP/0.9")) {
+ // write status line
+ headerStringBuffer.append(httpVersion).append(" ")
+ .append(Integer.toString(httpStatusCode)).append(" ")
+ .append(httpStatusText).append("\r\n");
+
// prepare header
if (!header.containsKey(httpHeader.DATE))
header.put(httpHeader.DATE, httpc.dateString(httpc.nowDate()));
diff --git a/source/de/anomic/http/httpdFileHandler.java b/source/de/anomic/http/httpdFileHandler.java
index 78f2ada7c..5d1d1d051 100644
--- a/source/de/anomic/http/httpdFileHandler.java
+++ b/source/de/anomic/http/httpdFileHandler.java
@@ -662,8 +662,8 @@ public final class httpdFileHandler extends httpdAbstractHandler implements http
}
// write the array to the client
- long contentLength = method.equals(httpHeader.METHOD_HEAD)?-1:result.length;
- String contentEncoding = method.equals(httpHeader.METHOD_HEAD)?null:(zipContent)?"gzip":null;
+ long contentLength = result.length;
+ String contentEncoding = (zipContent)?"gzip":null;
httpd.sendRespondHeader(this.connectionProperties, out, httpVersion, 200, null, mimeType, contentLength, targetDate, null, tp.getOutgoingHeader(), contentEncoding, null, nocache);
if (! method.equals(httpHeader.METHOD_HEAD)) {
Thread.sleep(200); // this solved the message problem (!!)
@@ -720,8 +720,8 @@ public final class httpdFileHandler extends httpdAbstractHandler implements http
// write the file to the client
targetDate = new Date(targetFile.lastModified());
- long contentLength = method.equals(httpHeader.METHOD_HEAD)?-1:(zipContent)?-1:targetFile.length()-rangeStartOffset;
- String contentEncoding = method.equals(httpHeader.METHOD_HEAD)?null:(zipContent)?"gzip":null;
+ long contentLength = (zipContent)?-1:targetFile.length()-rangeStartOffset;
+ String contentEncoding = (zipContent)?"gzip":null;
String transferEncoding = (!httpVersion.equals(httpHeader.HTTP_VERSION_1_1))?null:(zipContent)?"chunked":null;
if (!httpVersion.equals(httpHeader.HTTP_VERSION_1_1) && zipContent) forceConnectionClose();