Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

*) bugfix for handling of ResourceInfo object in proxy

thelia5ed86105bb3
diff --git a/source/de/anomic/http/httpdProxyHandler.java b/source/de/anomic/http/httpdProxyHandler.java
index fe18a6315..7f81554bb 100644
--- a/source/de/anomic/http/httpdProxyHandler.java
+++ b/source/de/anomic/http/httpdProxyHandler.java
@@ -415,9 +415,17 @@ public final class httpdProxyHandler extends httpdAbstractHandler implements htt
// decide wether to use a cache entry or connect to the network
File cacheFile = cacheManager.getCachePath(url);
+
+ httpHeader cachedResponseHeader = null;
ResourceInfo cachedResInfo = (ResourceInfo) cacheManager.loadResourceInfo(url);
- httpHeader cachedResponseHeader = (cachedResInfo == null)?null:cachedResInfo.getResponseHeader();
- boolean cacheExists = ((cacheFile.isFile()) && (cachedResponseHeader != null));
+ if (cachedResInfo != null) {
+ // set the new request header (needed by function shallUseCacheForProxy)
+ cachedResInfo.setRequestHeader(requestHeader);
+
+ // get the cached response header
+ cachedResponseHeader = cachedResInfo.getResponseHeader();
+ }
+ boolean cacheExists = cacheFile.isFile() && (cachedResponseHeader != null);
// why are files unzipped upon arrival? why not zip all files in cache?
// This follows from the following premises
@@ -457,12 +465,10 @@ public final class httpdProxyHandler extends httpdAbstractHandler implements htt
if (yacyCore.getOnlineMode() == 0) {
if (cacheExists) {
fulfillRequestFromCache(conProp,url,ext,requestHeader,cachedResponseHeader,cacheFile,respond);
- }
- else {
+ } else {
httpd.sendRespondError(conProp,respond,4,404,null,"URL not availabe in Cache",null);
}
- }
- else if (cacheExists && cacheEntry.shallUseCacheForProxy()) {
+ } else if (cacheExists && cacheEntry.shallUseCacheForProxy()) {
fulfillRequestFromCache(conProp,url,ext,requestHeader,cachedResponseHeader,cacheFile,respond);
} else {
fulfillRequestFromWeb(conProp,url,ext,requestHeader,cachedResponseHeader,cacheFile,respond);
diff --git a/source/de/anomic/plasma/cache/http/ResourceInfo.java b/source/de/anomic/plasma/cache/http/ResourceInfo.java
index 02bd80812..396304572 100644
--- a/source/de/anomic/plasma/cache/http/ResourceInfo.java
+++ b/source/de/anomic/plasma/cache/http/ResourceInfo.java
@@ -148,6 +148,10 @@ public class ResourceInfo implements IResourceInfo {
public String getUrlHash() {
return this.urlHash;
}
+
+ public void setRequestHeader(httpHeader reqestHeader) {
+ this.requestHeader = reqestHeader;
+ }
/**
* @see de.anomic.plasma.cache.IResourceInfo#shallIndexCacheForCrawler()