From e974d0cb99bc3d3cbc3c792148d2b4b046fe1d52 Mon Sep 17 00:00:00 2001 From: hermens Date: Thu, 16 Feb 2006 10:27:21 +0000 Subject: [PATCH] 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 git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@1664 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- source/de/anomic/http/httpd.java | 12 ++++++------ source/de/anomic/http/httpdFileHandler.java | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) 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();