Skip to content

Commit

Permalink
Improve compliance to rfc
Browse files Browse the repository at this point in the history
*) 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
  • Loading branch information
hermens committed Feb 16, 2006
1 parent 556d242 commit e974d0c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions source/de/anomic/http/httpd.java
Expand Up @@ -1275,13 +1275,13 @@ else if (httpVersion.equals(httpHeader.HTTP_VERSION_1_1) && httpHeader.http1_1.c

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()));
Expand Down
8 changes: 4 additions & 4 deletions source/de/anomic/http/httpdFileHandler.java
Expand Up @@ -662,8 +662,8 @@ public void doResponse(Properties conProp, httpHeader requestHeader, OutputStrea
}

// 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 (!!)
Expand Down Expand Up @@ -720,8 +720,8 @@ public void doResponse(Properties conProp, httpHeader requestHeader, OutputStrea

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

Expand Down

0 comments on commit e974d0c

Please sign in to comment.