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
pull/1/head
hermens 19 years ago
parent 556d242be0
commit e974d0cb99

@ -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()));

@ -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();

Loading…
Cancel
Save