*) fixes for httpd

- don't send Body on HEAD requests
  - don't send a Last-modified: date, that is later then Date:
  - Use Cache-control instead of Pragma with HTTP/1.1
  - don't send header with HTTP/0.9



git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@1198 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
hermens 20 years ago
parent 5a627a690f
commit 35cf6712b2

@ -1191,12 +1191,17 @@ public final class httpd implements serverHandler {
) throws IOException {
httpHeader headers = new httpHeader();
Date now = new Date(System.currentTimeMillis());
headers.put(httpHeader.SERVER, "AnomicHTTPD (www.anomic.de)");
headers.put(httpHeader.DATE, httpc.dateString(httpc.nowDate()));
headers.put(httpHeader.DATE, httpc.dateString(now));
if (moddate.after(now)) moddate = now;
headers.put(httpHeader.LAST_MODIFIED, httpc.dateString(moddate));
if (nocache) headers.put(httpHeader.PRAGMA, "no-cache");
if (nocache) {
if (httpVersion.toUpperCase().equals(headers.HTTP_VERSION_1_1)) headers.put(httpHeader.CACHE_CONTROL, "no-cache");
else headers.put(httpHeader.PRAGMA, "no-cache");
}
if (contentLength > 0) headers.put(httpHeader.CONTENT_TYPE, (contentType == null)? "text/html" : contentType);
if (contentLength > 0) headers.put(httpHeader.CONTENT_LENGTH, Long.toString(contentLength));
if (cookie != null) headers.put(httpHeader.SET_COOKIE, cookie);
@ -1232,6 +1237,8 @@ public final class httpd implements serverHandler {
if (header == null) header = new httpHeader();
try {
// "HTTP/0.9" does not have a header in the response
if (! httpVersion.toUpperCase().equals("HTTP/0.9")) {
if ((httpStatusText == null)||(httpStatusText.length()==0)) {
if (httpVersion.equals(httpHeader.HTTP_VERSION_1_0) && httpHeader.http1_0.containsKey(Integer.toString(httpStatusCode)))
httpStatusText = (String) httpHeader.http1_0.get(Integer.toString(httpStatusCode));
@ -1291,6 +1298,7 @@ public final class httpd implements serverHandler {
// sending headers to the client
respond.write(headerStringBuffer.toString().getBytes());
}
respond.flush();
conProp.put(httpHeader.CONNECTION_PROP_PROXY_RESPOND_HEADER,header);

@ -488,10 +488,12 @@ public final class httpdFileHandler extends httpdAbstractHandler implements http
baos.close(); baos = null;
// write the array to the client
httpd.sendRespondHeader(this.connectionProperties, out, "HTTP/1.1", 200, null, mimeType, result.length, targetDate, null, null, null, null, nocache);
httpd.sendRespondHeader(this.connectionProperties, out, httpVersion, 200, null, mimeType, result.length, targetDate, null, null, null, null, nocache);
if (! method.equals(httpHeader.METHOD_HEAD)) {
Thread.sleep(200); // see below
serverFileUtils.write(result, out);
}
}
} else if ((targetClass != null) && (path.endsWith(".stream"))) {
// call rewrite-class
requestHeader.put("CLIENTIP", conProp.getProperty("CLIENTIP"));
@ -671,8 +673,10 @@ public final class httpdFileHandler extends httpdAbstractHandler implements http
// write the array to the client
httpd.sendRespondHeader(this.connectionProperties, out, httpVersion, 200, null, mimeType, result.length, targetDate, null, null, (zipContent)?"gzip":null, null, nocache);
if (! method.equals(httpHeader.METHOD_HEAD)) {
Thread.sleep(200); // this solved the message problem (!!)
serverFileUtils.write(result, out);
}
} else {
httpd.sendRespondError(conProp,out,3,404,"File not Found",null,null);
return;

Loading…
Cancel
Save