mirror of
https://github.com/yacy/yacy_search_server.git
synced 2024-09-19 00:01:41 +02:00
proxy fixed 'not modified' http://forum.yacy-websuche.de/viewtopic.php?f=6&t=1419
git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@5133 6c8d7289-2bf4-0310-a012-ef5d649a1542
This commit is contained in:
parent
bd0318ba81
commit
d60b2b198d
|
@ -561,6 +561,7 @@ public final class httpdProxyHandler {
|
|||
if (theLogger.isFine()) theLogger.logFine(reqID +" create direct passthrough for URL " + url + ", extension '" + ext + "', mime-type '" + responseHeader.mime() + "'");
|
||||
} else {
|
||||
// handle text stuff (encoding and so on)
|
||||
final Charset charSet = responseHeader.getCharSet();
|
||||
if (
|
||||
(!transformer.isIdentityTransformer()) &&
|
||||
(plasmaParser.supportedHTMLContent(url,responseHeader.mime()))
|
||||
|
@ -568,12 +569,11 @@ public final class httpdProxyHandler {
|
|||
// make a transformer
|
||||
if (theLogger.isFine()) theLogger.logFine(reqID +" create transformer for URL " + url);
|
||||
//hfos = new htmlFilterOutputStream((gzippedOut != null) ? gzippedOut : ((chunkedOut != null)? chunkedOut : respond), null, transformer, (ext.length() == 0));
|
||||
final Charset charSet = responseHeader.getCharSet();
|
||||
textOutput = new htmlFilterWriter(outStream,charSet, null, transformer, (ext.length() == 0));
|
||||
} else {
|
||||
// simply pass through without parsing
|
||||
if (theLogger.isFine()) theLogger.logFine(reqID +" create text passthrough for URL " + url + ", extension '" + ext + "', mime-type '" + responseHeader.mime() + "'");
|
||||
textOutput = new OutputStreamWriter(outStream, responseHeader.getCharSet());
|
||||
textOutput = new OutputStreamWriter(outStream, charSet);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -596,6 +596,8 @@ public final class httpdProxyHandler {
|
|||
res.getStatusLine().substring(4), // status text
|
||||
responseHeader);
|
||||
|
||||
if(hasBody(res.getStatusCode())) {
|
||||
|
||||
final String storeError = cacheEntry.shallStoreCacheForProxy();
|
||||
final boolean storeHTCache = cacheEntry.profile().storeHTCache();
|
||||
final boolean isSupportedContent = plasmaParser.supportedContent(plasmaParser.PARSER_MODE_PROXY,cacheEntry.url(),cacheEntry.getMimeType());
|
||||
|
@ -720,6 +722,7 @@ public final class httpdProxyHandler {
|
|||
chunkedOut.finish();
|
||||
chunkedOut.flush();
|
||||
}
|
||||
} // end hasBody
|
||||
} finally {
|
||||
// if opened ...
|
||||
if(res != null) {
|
||||
|
@ -734,6 +737,23 @@ public final class httpdProxyHandler {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* determines if the response should have a body
|
||||
*
|
||||
* @param statusCode
|
||||
* @param responseHeader
|
||||
* @return
|
||||
*/
|
||||
private static boolean hasBody(final int statusCode) {
|
||||
// "All 1xx (informational), 204 (no content), and 304 (not modified) responses MUST NOT
|
||||
// include a message-body."
|
||||
// [RFC 2616 HTTP/1.1, Sect. 4.3] and like [RFC 1945 HTTP/1.0, Sect. 7.2]
|
||||
if((statusCode >= 100 && statusCode < 200) || statusCode == 204 || statusCode == 304) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void fulfillRequestFromCache(
|
||||
final Properties conProp,
|
||||
final yacyURL url,
|
||||
|
|
Loading…
Reference in New Issue
Block a user