Skip to content

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

modifications towards a single database operation to read/write http header and cached file at once: - removed distinction between header file types for http and ftp; ftp is simulated by using http properties - removed all old resourceInfo classes that handled this distinction - introduced a new distinction between http request and http response objects - unified new response objects with two other object types that had been introduced elsewhere - changed all servlet call methods to use the new http request header object type - divided static object keys for http header properties into request and response types - refactoring here and there (a large number of type changes and many methods merged/moved)

orbiter536e77e8b78d
diff --git a/build.properties b/build.properties
index 19c3c4fbc..68a43dccd 100644
--- a/build.properties
+++ b/build.properties
@@ -3,7 +3,7 @@ javacSource=1.5
javacTarget=1.5
# Release Configuration
-releaseVersion=0.594
+releaseVersion=0.595
stdReleaseFile=yacy_v${releaseVersion}_${DSTAMP}_${releaseNr}.tar.gz
embReleaseFile=yacy_emb_v${releaseVersion}_${DSTAMP}_${releaseNr}.tar.gz
proReleaseFile=yacy_pro_v${releaseVersion}_${DSTAMP}_${releaseNr}.tar.gz
diff --git a/htroot/AccessTracker_p.java b/htroot/AccessTracker_p.java
index fa2ac84c3..bdee8aa4f 100644
--- a/htroot/AccessTracker_p.java
+++ b/htroot/AccessTracker_p.java
@@ -33,7 +33,7 @@ import java.util.TreeMap;
import java.util.TreeSet;
import java.util.Map.Entry;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.net.natLib;
import de.anomic.plasma.plasmaSearchQuery;
import de.anomic.plasma.plasmaSwitchboard;
@@ -53,7 +53,7 @@ public class AccessTracker_p {
return accessClone;
}
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
// return variable that accumulates replacements
diff --git a/htroot/Banner.java b/htroot/Banner.java
index bff20bcf0..b9c3d4254 100644
--- a/htroot/Banner.java
+++ b/htroot/Banner.java
@@ -31,7 +31,7 @@ import java.io.IOException;
import javax.imageio.ImageIO;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaGrafics;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
@@ -42,7 +42,7 @@ import de.anomic.ymage.ymageMatrix;
/** draw a banner with information about the peer */
public class Banner {
- public static ymageMatrix respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) throws IOException {
+ public static ymageMatrix respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) throws IOException {
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
final String IMAGE = "htroot/env/grafics/yacy.gif";
int width = 468;
diff --git a/htroot/BlacklistCleaner_p.java b/htroot/BlacklistCleaner_p.java
index 7af740b6e..810ef184a 100644
--- a/htroot/BlacklistCleaner_p.java
+++ b/htroot/BlacklistCleaner_p.java
@@ -44,7 +44,7 @@ import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import de.anomic.data.listManager;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.index.indexAbstractReferenceBlacklist;
import de.anomic.index.indexDefaultReferenceBlacklist;
import de.anomic.index.indexReferenceBlacklist;
@@ -71,7 +71,7 @@ public class BlacklistCleaner_p {
indexDefaultReferenceBlacklist.class
};
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final serverObjects prop = new serverObjects();
// initialize the list manager
diff --git a/htroot/Blacklist_p.java b/htroot/Blacklist_p.java
index 1675b38cd..1b99f9634 100644
--- a/htroot/Blacklist_p.java
+++ b/htroot/Blacklist_p.java
@@ -40,7 +40,7 @@ import java.util.Iterator;
import java.util.TreeMap;
import de.anomic.data.listManager;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.index.indexAbstractReferenceBlacklist;
import de.anomic.index.indexReferenceBlacklist;
import de.anomic.plasma.plasmaSwitchboard;
@@ -55,7 +55,7 @@ public class Blacklist_p {
private final static String BLACKLIST = "blackLists_";
private final static String BLACKLIST_SHARED = "BlackLists.Shared";
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
// initialize the list manager
@@ -378,7 +378,7 @@ prop.putHTML("asd", "0");
* @return null if no error occured, else a String to put into LOCATION
*/
private static String addBlacklistEntry(final String blacklistToUse, String newEntry,
- final httpHeader header, final String[] supportedBlacklistTypes) {
+ final httpRequestHeader header, final String[] supportedBlacklistTypes) {
if (blacklistToUse == null || blacklistToUse.trim().length() == 0) {
return "";
@@ -430,7 +430,7 @@ prop.putHTML("asd", "0");
* @return null if no error occured, else a String to put into LOCATION
*/
private static String deleteBlacklistEntry(final String blacklistToUse, String oldEntry,
- final httpHeader header, final String[] supportedBlacklistTypes) {
+ final httpRequestHeader header, final String[] supportedBlacklistTypes) {
if (blacklistToUse == null || blacklistToUse.trim().length() == 0) {
return "";
diff --git a/htroot/Blog.java b/htroot/Blog.java
index 442a11b2d..5492c7176 100644
--- a/htroot/Blog.java
+++ b/htroot/Blog.java
@@ -37,7 +37,7 @@ import java.util.Iterator;
import de.anomic.data.blogBoard;
import de.anomic.data.userDB;
import de.anomic.http.HttpClient;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
@@ -55,7 +55,7 @@ public class Blog {
return SimpleFormatter.format(date);
}
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
final serverObjects prop = new serverObjects();
blogBoard.BlogEntry page = null;
@@ -67,7 +67,7 @@ public class Blog {
prop.put("display", 1); // Fixed to 1
- final boolean xml = (header.get(httpHeader.CONNECTION_PROP_PATH)).endsWith(".xml");
+ final boolean xml = (header.get(httpRequestHeader.CONNECTION_PROP_PATH)).endsWith(".xml");
final String address = sb.webIndex.seedDB.mySeed().getPublicAddress();
if(hasRights) {
@@ -86,7 +86,7 @@ public class Blog {
final int num = post.getInt("num",10); //indicates how many entries should be shown
if(!hasRights){
- final userDB.Entry userentry = sb.userDB.proxyAuth((String)header.get(httpHeader.AUTHORIZATION, "xxxxxx"));
+ final userDB.Entry userentry = sb.userDB.proxyAuth((String)header.get(httpRequestHeader.AUTHORIZATION, "xxxxxx"));
if(userentry != null && userentry.hasRight(userDB.Entry.BLOG_RIGHT)){
hasRights=true;
} else if(post.containsKey("login")) {
@@ -96,7 +96,7 @@ public class Blog {
}
String pagename = post.get("page", DEFAULT_PAGE);
- final String ip = (String)header.get(httpHeader.CONNECTION_PROP_CLIENTIP, "127.0.0.1");
+ final String ip = (String)header.get(httpRequestHeader.CONNECTION_PROP_CLIENTIP, "127.0.0.1");
String StrAuthor = post.get("author", "");
diff --git a/htroot/BlogComments.java b/htroot/BlogComments.java
index d826ad0fc..227542319 100644
--- a/htroot/BlogComments.java
+++ b/htroot/BlogComments.java
@@ -40,7 +40,7 @@ import de.anomic.data.blogBoardComments;
import de.anomic.data.messageBoard;
import de.anomic.data.userDB;
import de.anomic.data.blogBoard.BlogEntry;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverFileUtils;
import de.anomic.server.serverObjects;
@@ -57,7 +57,7 @@ public class BlogComments {
return SimpleFormatter.format(date);
}
- public static serverObjects respond(final httpHeader header, serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, serverObjects post, final serverSwitch<?> env) {
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
final serverObjects prop = new serverObjects();
blogBoard.BlogEntry page = null;
@@ -72,7 +72,7 @@ public class BlogComments {
}
if(!hasRights){
- final userDB.Entry userentry = sb.userDB.proxyAuth((String)header.get(httpHeader.AUTHORIZATION, "xxxxxx"));
+ final userDB.Entry userentry = sb.userDB.proxyAuth((String)header.get(httpRequestHeader.AUTHORIZATION, "xxxxxx"));
if(userentry != null && userentry.hasRight(userDB.Entry.BLOG_RIGHT)){
hasRights=true;
}
@@ -83,7 +83,7 @@ public class BlogComments {
}
final String pagename = post.get("page", "blog_default");
- final String ip = post.get(httpHeader.CONNECTION_PROP_CLIENTIP, "127.0.0.1");
+ final String ip = post.get(httpRequestHeader.CONNECTION_PROP_CLIENTIP, "127.0.0.1");
String StrAuthor = post.get("author", "anonymous");
diff --git a/htroot/Bookmarks.java b/htroot/Bookmarks.java
index c8965d7b1..29107f216 100644
--- a/htroot/Bookmarks.java
+++ b/htroot/Bookmarks.java
@@ -41,7 +41,7 @@ import de.anomic.data.listManager;
import de.anomic.data.userDB;
import de.anomic.data.bookmarksDB.Tag;
import de.anomic.http.HttpClient;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.index.indexURLReference;
import de.anomic.plasma.plasmaParserDocument;
import de.anomic.plasma.plasmaSnippetCache;
@@ -68,7 +68,7 @@ public class Bookmarks {
final static boolean TAGS = false;
final static boolean FOLDERS = true;
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
int max_count = 10;
int start=0;
diff --git a/htroot/CacheAdmin_p.java b/htroot/CacheAdmin_p.java
index f7826f34d..5944b5f62 100644
--- a/htroot/CacheAdmin_p.java
+++ b/htroot/CacheAdmin_p.java
@@ -44,13 +44,12 @@ import java.util.TreeSet;
import de.anomic.htmlFilter.htmlFilterContentScraper;
import de.anomic.htmlFilter.htmlFilterImageEntry;
import de.anomic.htmlFilter.htmlFilterWriter;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
+import de.anomic.http.httpResponseHeader;
import de.anomic.plasma.plasmaHTCache;
import de.anomic.plasma.plasmaParserDocument;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.plasma.plasmaSwitchboardConstants;
-import de.anomic.plasma.cache.IResourceInfo;
-import de.anomic.plasma.cache.UnsupportedProtocolException;
import de.anomic.server.serverFileUtils;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
@@ -66,7 +65,6 @@ public class CacheAdmin_p {
private static final int HtmlFile = 0;
private static final int NotCached = 1;
private static final int Image = 2;
- private static final int ProtocolError = 3;
private static final int SecurityError = 4;
public static final class Filter implements FilenameFilter {
@@ -78,7 +76,7 @@ public class CacheAdmin_p {
}
}
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final plasmaSwitchboard switchboard = (plasmaSwitchboard) env;
final serverObjects prop = new serverObjects();
@@ -116,11 +114,11 @@ public class CacheAdmin_p {
info.ensureCapacity(10000);
try {
- final IResourceInfo resInfo = plasmaHTCache.loadResourceInfo(url);
- if (resInfo == null) {
+ final httpResponseHeader responseHeader = plasmaHTCache.loadResponseHeader(url);
+ if (responseHeader == null) {
prop.put("info_type", NotCached);
} else {
- formatHeader(prop, resInfo.getMap());
+ formatHeader(prop, responseHeader);
final String ff = file.toString();
final int dotpos = ff.lastIndexOf('.');
@@ -137,9 +135,9 @@ public class CacheAdmin_p {
final htmlFilterContentScraper scraper = new htmlFilterContentScraper(url);
//final OutputStream os = new htmlFilterOutputStream(null, scraper, null, false);
final Writer writer = new htmlFilterWriter(null,null,scraper,null,false);
- String sourceCharset = resInfo.getCharacterEncoding();
+ String sourceCharset = responseHeader.getCharacterEncoding();
if (sourceCharset == null) sourceCharset = "UTF-8";
- final String mimeType = resInfo.getMimeType();
+ final String mimeType = responseHeader.mime();
serverFileUtils.copy(file, Charset.forName(sourceCharset), writer);
writer.close();
@@ -177,8 +175,6 @@ public class CacheAdmin_p {
}
} catch (final IOException e) {
prop.put("info_type", NotCached);
- } catch (final UnsupportedProtocolException e) {
- prop.put("info_type", ProtocolError);
} catch (final IllegalAccessException e) {
prop.put("info_type", SecurityError);
}
diff --git a/htroot/CacheResource_p.java b/htroot/CacheResource_p.java
index 3c9cd6522..272b56ba8 100644
--- a/htroot/CacheResource_p.java
+++ b/htroot/CacheResource_p.java
@@ -27,7 +27,7 @@
import java.io.File;
import java.io.IOException;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.plasma.plasmaSwitchboardConstants;
import de.anomic.server.serverFileUtils;
@@ -36,7 +36,7 @@ import de.anomic.server.serverSwitch;
public class CacheResource_p {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final plasmaSwitchboard switchboard = (plasmaSwitchboard) env;
final serverObjects prop = new serverObjects();
diff --git a/htroot/Collage.java b/htroot/Collage.java
index 4ff6bf21d..438bbb5bf 100755
--- a/htroot/Collage.java
+++ b/htroot/Collage.java
@@ -21,7 +21,7 @@
import java.util.Random;
import de.anomic.crawler.ResultImages;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverCore;
import de.anomic.server.serverObjects;
@@ -43,7 +43,7 @@ public class Collage {
private static long imgZIndex[] = new long[fifoMax];
private static final Random rand = new Random();
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final serverObjects prop = new serverObjects();
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
final boolean authenticated = sb.verifyAuthentication(header, false);
diff --git a/htroot/ConfigAccounts_p.java b/htroot/ConfigAccounts_p.java
index bde71f86b..73c722dee 100644
--- a/htroot/ConfigAccounts_p.java
+++ b/htroot/ConfigAccounts_p.java
@@ -31,7 +31,7 @@ import java.util.HashMap;
import java.util.Iterator;
import de.anomic.data.userDB;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.http.httpd;
import de.anomic.kelondro.kelondroBase64Order;
import de.anomic.plasma.plasmaSwitchboard;
@@ -41,7 +41,7 @@ import de.anomic.server.serverSwitch;
public class ConfigAccounts_p {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final serverObjects prop = new serverObjects();
final plasmaSwitchboard sb = plasmaSwitchboard.getSwitchboard();
userDB.Entry entry=null;
diff --git a/htroot/ConfigAppearance_p.java b/htroot/ConfigAppearance_p.java
index 2a13efd3f..6b2d85005 100644
--- a/htroot/ConfigAppearance_p.java
+++ b/htroot/ConfigAppearance_p.java
@@ -36,7 +36,7 @@ import java.util.Iterator;
import de.anomic.crawler.HTTPLoader;
import de.anomic.data.listManager;
import de.anomic.http.HttpClient;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverFileUtils;
import de.anomic.server.serverObjects;
@@ -46,7 +46,7 @@ import de.anomic.yacy.yacyURL;
public class ConfigAppearance_p {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final serverObjects prop = new serverObjects();
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
final String skinPath = new File(env.getRootPath(), env.getConfig("skinPath", "DATA/SKINS")).toString();
@@ -89,8 +89,8 @@ public class ConfigAppearance_p {
ArrayList<String> skinVector;
try {
final yacyURL u = new yacyURL(url, null);
- final httpHeader reqHeader = new httpHeader();
- reqHeader.put(httpHeader.USER_AGENT, HTTPLoader.yacyUserAgent);
+ final httpRequestHeader reqHeader = new httpRequestHeader();
+ reqHeader.put(httpRequestHeader.USER_AGENT, HTTPLoader.yacyUserAgent);
skinVector = nxTools.strings(HttpClient.wget(u.toString(), reqHeader, 10000), "UTF-8");
} catch (final IOException e) {
prop.put("status", "1");// unable to get URL
diff --git a/htroot/ConfigBasic.java b/htroot/ConfigBasic.java
index f924b1ebd..07ecc916f 100644
--- a/htroot/ConfigBasic.java
+++ b/htroot/ConfigBasic.java
@@ -31,7 +31,7 @@
import java.util.regex.Pattern;
import de.anomic.data.translator;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.http.httpd;
import de.anomic.http.httpdFileHandler;
import de.anomic.plasma.plasmaSwitchboard;
@@ -51,7 +51,7 @@ public class ConfigBasic {
private static final int NEXTSTEP_PEERPORT = 3;
private static final int NEXTSTEP_RECONNECT = 4;
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
// return variable that accumulates replacements
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
@@ -107,8 +107,8 @@ public class ConfigBasic {
reconnect = true;
String host = null;
- if (header.containsKey(httpHeader.HOST)) {
- host = header.get(httpHeader.HOST);
+ if (header.containsKey(httpRequestHeader.HOST)) {
+ host = header.get(httpRequestHeader.HOST);
final int idx = host.indexOf(":");
if (idx != -1) host = host.substring(0,idx);
} else {
diff --git a/htroot/ConfigLanguage_p.java b/htroot/ConfigLanguage_p.java
index 8cb467e74..0f6dbd395 100644
--- a/htroot/ConfigLanguage_p.java
+++ b/htroot/ConfigLanguage_p.java
@@ -39,7 +39,7 @@ import de.anomic.crawler.HTTPLoader;
import de.anomic.data.listManager;
import de.anomic.data.translator;
import de.anomic.http.HttpClient;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
import de.anomic.tools.nxTools;
@@ -48,7 +48,7 @@ import de.anomic.yacy.yacyURL;
public class ConfigLanguage_p {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
//listManager.switchboard = (plasmaSwitchboard) env;
final serverObjects prop = new serverObjects();
final String langPath = env.getConfigPath("locale.work", "DATA/LOCALE/locales").getAbsolutePath();
@@ -78,8 +78,8 @@ public class ConfigLanguage_p {
ArrayList<String> langVector;
try{
final yacyURL u = new yacyURL(url, null);
- final httpHeader reqHeader = new httpHeader();
- reqHeader.put(httpHeader.USER_AGENT, HTTPLoader.yacyUserAgent);
+ final httpRequestHeader reqHeader = new httpRequestHeader();
+ reqHeader.put(httpRequestHeader.USER_AGENT, HTTPLoader.yacyUserAgent);
langVector = nxTools.strings(HttpClient.wget(u.toString(), reqHeader, 10000), "UTF-8");
}catch(final IOException e){
prop.put("status", "1");//unable to get url
diff --git a/htroot/ConfigNetwork_p.java b/htroot/ConfigNetwork_p.java
index c2f3ab12f..04ee53769 100644
--- a/htroot/ConfigNetwork_p.java
+++ b/htroot/ConfigNetwork_p.java
@@ -28,7 +28,7 @@
import java.io.File;
import java.util.HashSet;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.http.httpd;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.plasma.plasmaSwitchboardConstants;
@@ -40,7 +40,7 @@ import de.anomic.server.serverSwitch;
public class ConfigNetwork_p {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
final serverObjects prop = new serverObjects();
diff --git a/htroot/ConfigProfile_p.java b/htroot/ConfigProfile_p.java
index 0921cd349..72dd77057 100644
--- a/htroot/ConfigProfile_p.java
+++ b/htroot/ConfigProfile_p.java
@@ -35,7 +35,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
@@ -44,7 +44,7 @@ import de.anomic.yacy.yacyNewsRecord;
public class ConfigProfile_p {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
final serverObjects prop = new serverObjects();
final Properties profile = new Properties();
diff --git a/htroot/ConfigProperties_p.java b/htroot/ConfigProperties_p.java
index 4d7bd7144..0fad020ad 100644
--- a/htroot/ConfigProperties_p.java
+++ b/htroot/ConfigProperties_p.java
@@ -33,13 +33,13 @@ import java.util.Collections;
import java.util.Iterator;
import java.util.List;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
public class ConfigProperties_p {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
// return variable that accumulates replacements
final serverObjects prop = new serverObjects();
int count=0;
diff --git a/htroot/ConfigRobotsTxt_p.java b/htroot/ConfigRobotsTxt_p.java
index 3d4f944ae..63111c7ed 100644
--- a/htroot/ConfigRobotsTxt_p.java
+++ b/htroot/ConfigRobotsTxt_p.java
@@ -29,7 +29,7 @@
// javac -classpath .:../classes ConfigRobotsTxt_p.java
// if the shell's current path is HTROOT
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.http.httpdRobotsTxtConfig;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.plasma.plasmaSwitchboardConstants;
@@ -39,7 +39,7 @@ import de.anomic.server.servletProperties;
public class ConfigRobotsTxt_p {
- public static servletProperties respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static servletProperties respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
final servletProperties prop = new servletProperties();
diff --git a/htroot/ConfigUpdate_p.java b/htroot/ConfigUpdate_p.java
index 3bc581252..cfca013f1 100644
--- a/htroot/ConfigUpdate_p.java
+++ b/htroot/ConfigUpdate_p.java
@@ -30,7 +30,7 @@ import java.util.Date;
import java.util.Iterator;
import java.util.TreeSet;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
@@ -40,7 +40,7 @@ import de.anomic.yacy.yacyVersion;
public class ConfigUpdate_p {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
// return variable that accumulates replacements
final serverObjects prop = new serverObjects();
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
diff --git a/htroot/Connections_p.java b/htroot/Connections_p.java
index 7837d2240..76b65a643 100644
--- a/htroot/Connections_p.java
+++ b/htroot/Connections_p.java
@@ -35,7 +35,7 @@ import java.util.Set;
import de.anomic.http.HttpConnectionInfo;
import de.anomic.http.JakartaCommonsHttpClient;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.http.httpd;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverCore;
@@ -50,7 +50,7 @@ import de.anomic.yacy.yacySeed;
public final class Connections_p {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
// return variable that accumulates replacements
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
final serverObjects prop = new serverObjects();
@@ -148,7 +148,7 @@ public final class Connections_p {
final Properties conProp = (Properties) currentHttpd.getConProp().clone();
// getting the destination host
- dest = conProp.getProperty(httpHeader.CONNECTION_PROP_HOST);
+ dest = conProp.getProperty(httpRequestHeader.CONNECTION_PROP_HOST);
if (dest==null)continue;
} else if (cmdObj instanceof urlRedirectord) {
prot = "urlRedirector";
diff --git a/htroot/CookieMonitorIncoming_p.java b/htroot/CookieMonitorIncoming_p.java
index aee74e590..d25918ac3 100644
--- a/htroot/CookieMonitorIncoming_p.java
+++ b/htroot/CookieMonitorIncoming_p.java
@@ -29,14 +29,14 @@ import java.util.Iterator;
import java.util.Map;
import de.anomic.http.HttpClient;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
public class CookieMonitorIncoming_p {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> sb) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> sb) {
final plasmaSwitchboard switchboard = (plasmaSwitchboard) sb;
// return variable that accumulates replacements
diff --git a/htroot/CookieMonitorOutgoing_p.java b/htroot/CookieMonitorOutgoing_p.java
index faf033da2..0a0598cdc 100644
--- a/htroot/CookieMonitorOutgoing_p.java
+++ b/htroot/CookieMonitorOutgoing_p.java
@@ -29,14 +29,14 @@ import java.util.Iterator;
import java.util.Map;
import de.anomic.http.HttpClient;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
public class CookieMonitorOutgoing_p {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> sb) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> sb) {
final plasmaSwitchboard switchboard = (plasmaSwitchboard) sb;
// return variable that accumulates replacements
diff --git a/htroot/CookieTest_p.java b/htroot/CookieTest_p.java
index 5ee686a83..e9fdf27b9 100644
--- a/htroot/CookieTest_p.java
+++ b/htroot/CookieTest_p.java
@@ -30,14 +30,14 @@
import java.util.Iterator;
import java.util.Map;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpResponseHeader;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
import de.anomic.server.servletProperties;
public class CookieTest_p {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpResponseHeader header, final serverObjects post, final serverSwitch<?> env) {
// case if no values are requested
@@ -50,7 +50,7 @@ public class CookieTest_p {
final servletProperties prop = new servletProperties();
if(post.containsKey("act")&&post.get("act").equals("clear_cookie")) {
- final httpHeader outgoingHeader = new httpHeader();
+ final httpResponseHeader outgoingHeader = new httpResponseHeader();
final Iterator<Map.Entry<String, String>> it = header.entrySet().iterator();
Map.Entry<String, String> e;
while (it.hasNext()) {
@@ -77,7 +77,7 @@ public class CookieTest_p {
{
final String cookieName = post.get("cookie_name").trim();
final String cookieValue = post.get("cookie_value").trim();
- final httpHeader outgoingHeader=new httpHeader();
+ final httpResponseHeader outgoingHeader=new httpResponseHeader();
outgoingHeader.setCookie(cookieName,cookieValue);
prop.setOutgoingHeader(outgoingHeader);
diff --git a/htroot/CrawlProfileEditor_p.java b/htroot/CrawlProfileEditor_p.java
index cd429ff3b..21ce6c013 100644
--- a/htroot/CrawlProfileEditor_p.java
+++ b/htroot/CrawlProfileEditor_p.java
@@ -30,7 +30,7 @@ import java.util.Iterator;
import de.anomic.crawler.CrawlProfile;
import de.anomic.crawler.CrawlProfile.entry;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.plasma.plasmaWordIndex;
import de.anomic.server.serverObjects;
@@ -79,7 +79,7 @@ public class CrawlProfileEditor_p {
labels.add(new eentry(entry.XPSTOPW, "Parent stop-words", false, eentry.BOOLEAN));
}
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final servletProperties prop = new servletProperties();
final plasmaSwitchboard sb = (plasmaSwitchboard)env;
diff --git a/htroot/CrawlResults.java b/htroot/CrawlResults.java
index 045110773..7c863be40 100644
--- a/htroot/CrawlResults.java
+++ b/htroot/CrawlResults.java
@@ -28,7 +28,7 @@ import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.index.indexURLReference;
import de.anomic.plasma.plasmaHTCache;
import de.anomic.plasma.plasmaSwitchboard;
@@ -41,7 +41,7 @@ import de.anomic.yacy.yacyURL;
public class CrawlResults {
- public static serverObjects respond(final httpHeader header, serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, serverObjects post, final serverSwitch<?> env) {
// return variable that accumulates replacements
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
final serverObjects prop = new serverObjects();
@@ -77,7 +77,7 @@ public class CrawlResults {
if (((tabletype > 0) && (tabletype < 6)) ||
(post != null && (post.containsKey("clearlist") ||
post.containsKey("deleteentry")))) {
- final String authorization = ((String) header.get(httpHeader.AUTHORIZATION, "xxxxxx"));
+ final String authorization = ((String) header.get(httpRequestHeader.AUTHORIZATION, "xxxxxx"));
if (authorization.length() != 0) {
if (! sb.verifyAuthentication(header, true)){
// force log-in (again, because wrong password was given)
diff --git a/htroot/CrawlStart_p.java b/htroot/CrawlStart_p.java
index 616b6316c..c649c49dd 100644
--- a/htroot/CrawlStart_p.java
+++ b/htroot/CrawlStart_p.java
@@ -24,14 +24,14 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboardConstants;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
public class CrawlStart_p {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
// return variable that accumulates replacements
final serverObjects prop = new serverObjects();
diff --git a/htroot/FeedReader_p.java b/htroot/FeedReader_p.java
index f9a21ee0a..b0bddf976 100644
--- a/htroot/FeedReader_p.java
+++ b/htroot/FeedReader_p.java
@@ -23,7 +23,7 @@
import java.net.MalformedURLException;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
import de.anomic.server.servletProperties;
@@ -37,7 +37,7 @@ import de.anomic.yacy.yacyURL;
public class FeedReader_p {
- public static servletProperties respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static servletProperties respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final servletProperties prop = new servletProperties();
prop.put("page", "0");
diff --git a/htroot/IndexCleaner_p.java b/htroot/IndexCleaner_p.java
index 21edcd93d..bba735405 100755
--- a/htroot/IndexCleaner_p.java
+++ b/htroot/IndexCleaner_p.java
@@ -24,7 +24,7 @@
//along with this program; if not, write to the Free Software
//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.index.indexRepositoryReference;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.plasma.plasmaWordIndex;
@@ -35,7 +35,7 @@ public class IndexCleaner_p {
private static indexRepositoryReference.BlacklistCleaner urldbCleanerThread = null;
private static plasmaWordIndex.ReferenceCleaner indexCleanerThread = null;
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final serverObjects prop = new serverObjects();
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
prop.put("title", "DbCleanup_p");
diff --git a/htroot/IndexControlRWIs_p.java b/htroot/IndexControlRWIs_p.java
index 5544bdff5..eb24d0786 100644
--- a/htroot/IndexControlRWIs_p.java
+++ b/htroot/IndexControlRWIs_p.java
@@ -35,7 +35,7 @@ import java.util.Iterator;
import java.util.Set;
import de.anomic.data.listManager;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.index.indexAbstractReferenceBlacklist;
import de.anomic.index.indexContainer;
import de.anomic.index.indexRWIEntry;
@@ -55,7 +55,7 @@ import de.anomic.yacy.yacyURL;
public class IndexControlRWIs_p {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
// return variable that accumulates replacements
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
final serverObjects prop = new serverObjects();
diff --git a/htroot/IndexControlURLs_p.java b/htroot/IndexControlURLs_p.java
index 7e70480e8..d1a7dcd1b 100644
--- a/htroot/IndexControlURLs_p.java
+++ b/htroot/IndexControlURLs_p.java
@@ -30,7 +30,7 @@ import java.io.IOException;
import java.net.MalformedURLException;
import java.util.Iterator;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.index.indexRepositoryReference;
import de.anomic.index.indexURLReference;
import de.anomic.kelondro.kelondroBase64Order;
@@ -44,7 +44,7 @@ import de.anomic.yacy.yacyURL;
public class IndexControlURLs_p {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
// return variable that accumulates replacements
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
diff --git a/htroot/IndexCreateIndexingQueue_p.java b/htroot/IndexCreateIndexingQueue_p.java
index ea59f6e9c..603d927bf 100644
--- a/htroot/IndexCreateIndexingQueue_p.java
+++ b/htroot/IndexCreateIndexingQueue_p.java
@@ -29,7 +29,7 @@ import java.util.Iterator;
import de.anomic.crawler.IndexingStack;
import de.anomic.crawler.ZURL;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaHTCache;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverMemory;
@@ -40,7 +40,7 @@ import de.anomic.yacy.yacyURL;
public class IndexCreateIndexingQueue_p {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
// return variable that accumulates replacements
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
final serverObjects prop = new serverObjects();
@@ -67,7 +67,7 @@ public class IndexCreateIndexingQueue_p {
IndexingStack.QueueEntry entry = null;
while ((entry = sb.webIndex.queuePreStack.pop()) != null) {
if ((entry != null) && (entry.profile() != null) && (!(entry.profile().storeHTCache()))) {
- plasmaHTCache.deleteURLfromCache(entry.url());
+ plasmaHTCache.deleteURLfromCache(entry.url(), false);
}
}
sb.webIndex.queuePreStack.clear(); // reset file to clean up content completely
diff --git a/htroot/IndexCreateLoaderQueue_p.java b/htroot/IndexCreateLoaderQueue_p.java
index b1e950c90..69de3f2c8 100644
--- a/htroot/IndexCreateLoaderQueue_p.java
+++ b/htroot/IndexCreateLoaderQueue_p.java
@@ -25,7 +25,7 @@
// if the shell's current path is HTROOT
import de.anomic.crawler.CrawlEntry;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
@@ -33,7 +33,7 @@ import de.anomic.yacy.yacySeed;
public class IndexCreateLoaderQueue_p {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
// return variable that accumulates replacements
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
final serverObjects prop = new serverObjects();
diff --git a/htroot/IndexCreateWWWGlobalQueue_p.java b/htroot/IndexCreateWWWGlobalQueue_p.java
index 703ed9fb0..308621e4c 100644
--- a/htroot/IndexCreateWWWGlobalQueue_p.java
+++ b/htroot/IndexCreateWWWGlobalQueue_p.java
@@ -32,7 +32,7 @@ import java.util.Locale;
import de.anomic.crawler.CrawlEntry;
import de.anomic.crawler.CrawlProfile;
import de.anomic.crawler.NoticedURL;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
@@ -46,7 +46,7 @@ public class IndexCreateWWWGlobalQueue_p {
return dayFormatter.format(date);
}
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
// return variable that accumulates replacements
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
final serverObjects prop = new serverObjects();
diff --git a/htroot/IndexCreateWWWLocalQueue_p.java b/htroot/IndexCreateWWWLocalQueue_p.java
index 38903e4af..638a1708b 100644
--- a/htroot/IndexCreateWWWLocalQueue_p.java
+++ b/htroot/IndexCreateWWWLocalQueue_p.java
@@ -36,7 +36,7 @@ import java.util.regex.PatternSyntaxException;
import de.anomic.crawler.CrawlEntry;
import de.anomic.crawler.CrawlProfile;
import de.anomic.crawler.NoticedURL;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.plasma.plasmaWordIndex;
import de.anomic.server.serverObjects;
@@ -59,7 +59,7 @@ public class IndexCreateWWWLocalQueue_p {
private static final int INITIATOR = 5;
private static final int MODIFIED = 6;
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
// return variable that accumulates replacements
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
final serverObjects prop = new serverObjects();
diff --git a/htroot/IndexCreateWWWRemoteQueue_p.java b/htroot/IndexCreateWWWRemoteQueue_p.java
index c46fd41b9..e41d1d179 100644
--- a/htroot/IndexCreateWWWRemoteQueue_p.java
+++ b/htroot/IndexCreateWWWRemoteQueue_p.java
@@ -32,7 +32,7 @@ import java.util.Locale;
import de.anomic.crawler.CrawlEntry;
import de.anomic.crawler.CrawlProfile;
import de.anomic.crawler.NoticedURL;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
@@ -47,7 +47,7 @@ public class IndexCreateWWWRemoteQueue_p {
return dayFormatter.format(date);
}
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final servletProperties prop = new servletProperties();
final plasmaSwitchboard sb = (plasmaSwitchboard)env;
diff --git a/htroot/IndexImport_p.java b/htroot/IndexImport_p.java
index 694cb6719..de50483cb 100644
--- a/htroot/IndexImport_p.java
+++ b/htroot/IndexImport_p.java
@@ -34,7 +34,7 @@ import java.util.Date;
import de.anomic.crawler.Importer;
import de.anomic.crawler.NoticeURLImporter;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverByteBuffer;
import de.anomic.server.serverDate;
@@ -43,7 +43,7 @@ import de.anomic.server.serverSwitch;
public final class IndexImport_p {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
// return variable that accumulates replacements
final plasmaSwitchboard switchboard = (plasmaSwitchboard) env;
final serverObjects prop = new serverObjects();
diff --git a/htroot/IndexShare_p.java b/htroot/IndexShare_p.java
index f5aab120c..d39a8c0e1 100644
--- a/htroot/IndexShare_p.java
+++ b/htroot/IndexShare_p.java
@@ -28,7 +28,7 @@
//import java.net.*;
//import java.io.*;
//import de.anomic.tools.*;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.plasma.plasmaSwitchboardConstants;
import de.anomic.server.serverObjects;
@@ -36,7 +36,7 @@ import de.anomic.server.serverSwitch;
public class IndexShare_p {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
// return variable that accumulates replacements
final plasmaSwitchboard switchboard = (plasmaSwitchboard) env;
final serverObjects prop = new serverObjects();
diff --git a/htroot/IndexTransfer_p.java b/htroot/IndexTransfer_p.java
index 863dc02c4..5e4b5c7d7 100644
--- a/htroot/IndexTransfer_p.java
+++ b/htroot/IndexTransfer_p.java
@@ -34,7 +34,7 @@ import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.TreeMap;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverMemory;
import de.anomic.server.serverObjects;
@@ -43,7 +43,7 @@ import de.anomic.yacy.yacySeed;
public final class IndexTransfer_p {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
// return variable that accumulates replacements
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
final serverObjects prop = new serverObjects();
diff --git a/htroot/LogStatistics_p.java b/htroot/LogStatistics_p.java
index c092c24c8..4599ae387 100644
--- a/htroot/LogStatistics_p.java
+++ b/htroot/LogStatistics_p.java
@@ -31,7 +31,7 @@ import java.util.Hashtable;
import java.util.logging.Handler;
import java.util.logging.Logger;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
import de.anomic.server.logging.LogalizerHandler;
@@ -42,7 +42,7 @@ public class LogStatistics_p {
private static final String RESULTS = "results_";
@SuppressWarnings({ "unchecked", "boxing" })
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch env) {
final serverObjects prop = new serverObjects();
final Logger logger = Logger.getLogger("");
diff --git a/htroot/MessageSend_p.java b/htroot/MessageSend_p.java
index 8a809d3e8..b68c63d5f 100644
--- a/htroot/MessageSend_p.java
+++ b/htroot/MessageSend_p.java
@@ -30,7 +30,7 @@ import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
@@ -45,7 +45,7 @@ public class MessageSend_p {
}
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
final serverObjects prop = new serverObjects();
diff --git a/htroot/Messages_p.java b/htroot/Messages_p.java
index 1e3e09e36..0fe80b5f7 100644
--- a/htroot/Messages_p.java
+++ b/htroot/Messages_p.java
@@ -34,7 +34,7 @@ import java.util.TreeMap;
import de.anomic.data.messageBoard;
import de.anomic.http.HttpClient;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverFileUtils;
import de.anomic.server.serverObjects;
@@ -50,7 +50,7 @@ public class Messages_p {
return SimpleFormatter.format(date);
}
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
final serverObjects prop = new serverObjects();
@@ -126,7 +126,7 @@ public class Messages_p {
prop.putHTML("mode_messages_"+count+"_key", key, true);
prop.put("mode_messages_"+count+"_hash", message.authorHash());
- if ((header.get(httpHeader.CONNECTION_PROP_PATH)).endsWith(".rss")) {
+ if ((header.get(httpRequestHeader.CONNECTION_PROP_PATH)).endsWith(".rss")) {
// set the peer address
prop.put("mode_messages_"+count+"_peerAddress", peerAddress);
diff --git a/htroot/Network.java b/htroot/Network.java
index a65fb18be..d00bf4a77 100644
--- a/htroot/Network.java
+++ b/htroot/Network.java
@@ -37,7 +37,7 @@ import java.util.regex.PatternSyntaxException;
import de.anomic.crawler.HTTPLoader;
import de.anomic.http.HttpClient;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverCodings;
import de.anomic.server.serverDate;
@@ -53,13 +53,13 @@ public class Network {
private static final String STR_TABLE_LIST = "table_list_";
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> switchboard) {
+ public static serverObjects respond(final httpRequestHeader requestHeader, final serverObjects post, final serverSwitch<?> switchboard) {
final plasmaSwitchboard sb = (plasmaSwitchboard) switchboard;
final long start = System.currentTimeMillis();
// return variable that accumulates replacements
final serverObjects prop = new serverObjects();
- prop.setLocalized(!(header.get("PATH")).endsWith(".xml"));
+ prop.setLocalized(!(requestHeader.get("PATH")).endsWith(".xml"));
prop.putHTML("page_networkTitle", sb.getConfig("network.unit.description", "unspecified"));
prop.putHTML("page_networkName", sb.getConfig("network.unit.name", "unspecified"));
final boolean overview = (post == null) || (post.get("page", "0").equals("0"));
@@ -183,7 +183,7 @@ public class Network {
if (post.containsKey("addPeer")) {
// AUTHENTICATE
- if (!header.containsKey(httpHeader.AUTHORIZATION)) {
+ if (!requestHeader.containsKey(httpRequestHeader.AUTHORIZATION)) {
prop.putHTML("AUTHENTICATE","log-in");
return prop;
}
diff --git a/htroot/NetworkPicture.java b/htroot/NetworkPicture.java
index 919835427..02efa3c6a 100644
--- a/htroot/NetworkPicture.java
+++ b/htroot/NetworkPicture.java
@@ -24,7 +24,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaGrafics;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
@@ -34,7 +34,7 @@ import de.anomic.ymage.ymageMatrix;
/** draw a picture of the yacy network */
public class NetworkPicture {
- public static ymageMatrix respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static ymageMatrix respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
int width = 768;
diff --git a/htroot/News.java b/htroot/News.java
index ac73fe3ea..025d99cb7 100644
--- a/htroot/News.java
+++ b/htroot/News.java
@@ -30,7 +30,7 @@ import java.util.Map;
import java.util.Map.Entry;
import de.anomic.http.HttpClient;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverDate;
import de.anomic.server.serverObjects;
@@ -41,7 +41,7 @@ import de.anomic.yacy.yacySeed;
public class News {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
final serverObjects prop = new serverObjects();
final boolean overview = (post == null) || (post.get("page", "0").equals("0"));
diff --git a/htroot/PeerLoadPicture.java b/htroot/PeerLoadPicture.java
index 51b6a3bd3..6eb25c0d0 100644
--- a/htroot/PeerLoadPicture.java
+++ b/htroot/PeerLoadPicture.java
@@ -3,7 +3,7 @@ import java.awt.Image;
import java.util.HashMap;
import java.util.Iterator;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaGrafics;
import de.anomic.plasma.plasmaSwitchboardConstants;
import de.anomic.plasma.plasmaGrafics.CircleThreadPiece;
@@ -13,7 +13,7 @@ import de.anomic.server.serverSwitch;
public class PeerLoadPicture {
- public static Image respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static Image respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
int width = 800;
int height = 600;
diff --git a/htroot/PerformanceGraph.java b/htroot/PerformanceGraph.java
index 271fc6ed4..b49b7b2bc 100644
--- a/htroot/PerformanceGraph.java
+++ b/htroot/PerformanceGraph.java
@@ -24,7 +24,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaProfiling;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
@@ -33,7 +33,7 @@ import de.anomic.ymage.ymageMatrix;
public class PerformanceGraph {
- public static ymageMatrix respond(final httpHeader header, serverObjects post, final serverSwitch<?> env) {
+ public static ymageMatrix respond(final httpRequestHeader header, serverObjects post, final serverSwitch<?> env) {
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
if (post == null) post = new serverObjects();
diff --git a/htroot/PerformanceMemory_p.java b/htroot/PerformanceMemory_p.java
index 9d6309ed1..eceac8075 100644
--- a/htroot/PerformanceMemory_p.java
+++ b/htroot/PerformanceMemory_p.java
@@ -29,7 +29,7 @@ import java.io.File;
import java.util.Iterator;
import java.util.Map;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.kelondro.kelondroCache;
import de.anomic.kelondro.kelondroCachedRecords;
import de.anomic.kelondro.kelondroEcoTable;
@@ -47,7 +47,7 @@ public class PerformanceMemory_p {
private static final long MB = 1024 * KB;
private static Map<String, String> defaultSettings = null;
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
// return variable that accumulates replacements
final serverObjects prop = new serverObjects();
if (defaultSettings == null) {
diff --git a/htroot/PerformanceQueues_p.java b/htroot/PerformanceQueues_p.java
index f3d8be840..1452228c5 100644
--- a/htroot/PerformanceQueues_p.java
+++ b/htroot/PerformanceQueues_p.java
@@ -29,7 +29,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.plasma.plasmaSwitchboardConstants;
import de.anomic.server.serverBusyThread;
@@ -51,7 +51,7 @@ public class PerformanceQueues_p {
performanceProfiles.put("defaults/performance_dht.profile", "prefer DHT");
}
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> sb) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> sb) {
// return variable that accumulates replacements
final plasmaSwitchboard switchboard = (plasmaSwitchboard) sb;
final serverObjects prop = new serverObjects();
diff --git a/htroot/PerformanceSearch_p.java b/htroot/PerformanceSearch_p.java
index df05edfe7..cd4f6d3b6 100644
--- a/htroot/PerformanceSearch_p.java
+++ b/htroot/PerformanceSearch_p.java
@@ -27,7 +27,7 @@
import java.util.Date;
import java.util.Iterator;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaProfiling;
import de.anomic.server.serverObjects;
import de.anomic.server.serverProfiling;
@@ -35,7 +35,7 @@ import de.anomic.server.serverSwitch;
public class PerformanceSearch_p {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> sb) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> sb) {
// return variable that accumulates replacements
final serverObjects prop = new serverObjects();
diff --git a/htroot/ProxyIndexingMonitor_p.java b/htroot/ProxyIndexingMonitor_p.java
index 30a4515ba..e8fb87735 100644
--- a/htroot/ProxyIndexingMonitor_p.java
+++ b/htroot/ProxyIndexingMonitor_p.java
@@ -30,7 +30,7 @@
import java.io.File;
import java.io.IOException;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.plasma.plasmaSwitchboardConstants;
import de.anomic.server.serverObjects;
@@ -44,7 +44,7 @@ public class ProxyIndexingMonitor_p {
// if (date == null) return ""; else return dayFormatter.format(date);
// }
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
// return variable that accumulates replacements
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
final serverObjects prop = new serverObjects();
diff --git a/htroot/QuickCrawlLink_p.java b/htroot/QuickCrawlLink_p.java
index 53befcf75..dfa10b9f4 100644
--- a/htroot/QuickCrawlLink_p.java
+++ b/htroot/QuickCrawlLink_p.java
@@ -35,7 +35,7 @@ import java.net.URLDecoder;
import java.util.Date;
import de.anomic.crawler.CrawlProfile;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
@@ -51,7 +51,7 @@ public class QuickCrawlLink_p {
* @param env the serverSwitch object holding all runtime-data
* @return the rewrite-properties for the template
*/
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final serverObjects prop = new serverObjects();
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
@@ -61,7 +61,7 @@ public class QuickCrawlLink_p {
prop.put("mode", "0");
// getting the http host header
- final String hostSocket = header.get(httpHeader.CONNECTION_PROP_HOST);
+ final String hostSocket = header.get(httpRequestHeader.CONNECTION_PROP_HOST);
//String host = hostSocket;
int port = 80;
diff --git a/htroot/Ranking_p.java b/htroot/Ranking_p.java
index 3b271fe5e..8f173d367 100644
--- a/htroot/Ranking_p.java
+++ b/htroot/Ranking_p.java
@@ -29,7 +29,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSearchEvent;
import de.anomic.plasma.plasmaSearchQuery;
import de.anomic.plasma.plasmaSearchRankingProfile;
@@ -127,7 +127,7 @@ public class Ranking_p {
}
}
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
// clean up all search events
diff --git a/htroot/SearchEventPicture.java b/htroot/SearchEventPicture.java
index 9372c9af0..b7b1594fa 100644
--- a/htroot/SearchEventPicture.java
+++ b/htroot/SearchEventPicture.java
@@ -25,7 +25,7 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaGrafics;
import de.anomic.plasma.plasmaSearchEvent;
import de.anomic.plasma.plasmaSwitchboard;
@@ -37,7 +37,7 @@ import de.anomic.ymage.ymageMatrix;
public class SearchEventPicture {
- public static ymageMatrix respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static ymageMatrix respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
final String eventID = (String) header.get("event", plasmaSearchEvent.lastEventID);
if (eventID == null) return null;
diff --git a/htroot/SettingsAck_p.java b/htroot/SettingsAck_p.java
index 805a9e2de..357ba3a68 100644
--- a/htroot/SettingsAck_p.java
+++ b/htroot/SettingsAck_p.java
@@ -38,7 +38,7 @@ import java.util.StringTokenizer;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.http.httpRemoteProxyConfig;
import de.anomic.http.httpd;
import de.anomic.http.httpdProxyHandler;
@@ -59,13 +59,13 @@ public class SettingsAck_p {
private static boolean nothingChanged = false;
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
// return variable that accumulates replacements
final serverObjects prop = new serverObjects();
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
// get referer for backlink
- final String referer = header.get(httpHeader.REFERER);
+ final String referer = header.get(httpRequestHeader.REFERER);
prop.put("referer", (referer == null) ? "Settings_p.html" : referer);
//if (post == null) System.out.println("POST: NULL"); else System.out.println("POST: " + post.toString());
diff --git a/htroot/Settings_p.java b/htroot/Settings_p.java
index 7706270f0..20464e8db 100644
--- a/htroot/Settings_p.java
+++ b/htroot/Settings_p.java
@@ -29,7 +29,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaParser;
import de.anomic.plasma.plasmaParserConfig;
import de.anomic.plasma.plasmaSwitchboard;
@@ -42,7 +42,7 @@ import de.anomic.yacy.yacySeedUploader;
public final class Settings_p {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
// return variable that accumulates replacements
final serverObjects prop = new serverObjects();
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
@@ -162,7 +162,7 @@ public final class Settings_p {
}
// clientIP
- prop.putHTML("clientIP", (String) header.get(httpHeader.CONNECTION_PROP_CLIENTIP, "<unknown>"), true); // read an artificial header addendum
+ prop.putHTML("clientIP", (String) header.get(httpRequestHeader.CONNECTION_PROP_CLIENTIP, "<unknown>"), true); // read an artificial header addendum
/*
* seed upload settings
diff --git a/htroot/Status.java b/htroot/Status.java
index 08a7ad25d..204c225c7 100644
--- a/htroot/Status.java
+++ b/htroot/Status.java
@@ -29,7 +29,7 @@
import java.util.Date;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.http.httpd;
import de.anomic.http.httpdByteCountInputStream;
import de.anomic.http.httpdByteCountOutputStream;
@@ -51,7 +51,7 @@ public class Status {
private static final String SEEDSERVER = "seedServer";
private static final String PEERSTATUS = "peerStatus";
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
// return variable that accumulates replacements
final serverObjects prop = new serverObjects();
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
diff --git a/htroot/Steering.java b/htroot/Steering.java
index ff55159a4..5849b8bd1 100644
--- a/htroot/Steering.java
+++ b/htroot/Steering.java
@@ -29,7 +29,7 @@
import java.io.File;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
@@ -37,7 +37,7 @@ import de.anomic.yacy.yacyVersion;
public class Steering {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> ss) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> ss) {
if (post == null || ss == null) { return new serverObjects(); }
final plasmaSwitchboard sb = (plasmaSwitchboard) ss;
diff --git a/htroot/Supporter.java b/htroot/Supporter.java
index 2d82e4799..145c8a542 100644
--- a/htroot/Supporter.java
+++ b/htroot/Supporter.java
@@ -31,7 +31,7 @@ import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.index.indexReferenceBlacklist;
import de.anomic.kelondro.kelondroMScoreCluster;
import de.anomic.kelondro.kelondroNaturalOrder;
@@ -50,7 +50,7 @@ import de.anomic.yacy.yacyURL;
public class Supporter {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
final serverObjects prop = new serverObjects();
diff --git a/htroot/Surftips.java b/htroot/Surftips.java
index 29d284849..6b1fb1dd3 100644
--- a/htroot/Surftips.java
+++ b/htroot/Surftips.java
@@ -31,7 +31,7 @@ import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.index.indexReferenceBlacklist;
import de.anomic.kelondro.kelondroMScoreCluster;
import de.anomic.kelondro.kelondroNaturalOrder;
@@ -50,7 +50,7 @@ import de.anomic.yacy.yacyURL;
public class Surftips {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
final serverObjects prop = new serverObjects();
diff --git a/htroot/Threaddump_p.java b/htroot/Threaddump_p.java
index 26bec3b17..1e513d9e7 100644
--- a/htroot/Threaddump_p.java
+++ b/htroot/Threaddump_p.java
@@ -36,7 +36,7 @@ import java.util.Map;
import java.util.Map.Entry;
import de.anomic.data.htmlTools;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverFileUtils;
import de.anomic.server.serverObjects;
@@ -49,7 +49,7 @@ public class Threaddump_p {
private static final serverObjects prop = new serverObjects();
private static plasmaSwitchboard sb = null;
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
prop.clear();
sb = (plasmaSwitchboard) env;
diff --git a/htroot/User.java b/htroot/User.java
index b53f065e8..607314d1e 100644
--- a/htroot/User.java
+++ b/htroot/User.java
@@ -30,7 +30,8 @@
import java.io.IOException;
import de.anomic.data.userDB;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
+import de.anomic.http.httpResponseHeader;
import de.anomic.http.httpd;
import de.anomic.kelondro.kelondroBase64Order;
import de.anomic.plasma.plasmaSwitchboard;
@@ -41,7 +42,7 @@ import de.anomic.server.servletProperties;
public class User{
- public static servletProperties respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static servletProperties respond(final httpRequestHeader requestHeader, final serverObjects post, final serverSwitch<?> env) {
final servletProperties prop = new servletProperties();
final plasmaSwitchboard sb = plasmaSwitchboard.getSwitchboard();
userDB.Entry entry=null;
@@ -51,16 +52,16 @@ public class User{
prop.put("logged-in_limit", "0");
prop.put("status", "0");
//identified via HTTPPassword
- entry=sb.userDB.proxyAuth(((String) header.get(httpHeader.AUTHORIZATION, "xxxxxx")));
+ entry=sb.userDB.proxyAuth(((String) requestHeader.get(httpRequestHeader.AUTHORIZATION, "xxxxxx")));
if(entry != null){
prop.put("logged-in_identified-by", "1");
//try via cookie
}else{
- entry=sb.userDB.cookieAuth(header.getHeaderCookies());
+ entry=sb.userDB.cookieAuth(requestHeader.getHeaderCookies());
prop.put("logged-in_identified-by", "2");
//try via ip
if(entry == null){
- entry=sb.userDB.ipAuth(((String)header.get(httpHeader.CONNECTION_PROP_CLIENTIP, "xxxxxx")));
+ entry=sb.userDB.ipAuth(((String)requestHeader.get(httpRequestHeader.CONNECTION_PROP_CLIENTIP, "xxxxxx")));
if(entry != null){
prop.put("logged-in_identified-by", "0");
}
@@ -84,12 +85,11 @@ public class User{
prop.put("logged-in_limit_percent2", (100-percent)/3);
}
//logged in via static Password
- }else if(sb.verifyAuthentication(header, true)){
+ }else if(sb.verifyAuthentication(requestHeader, true)){
prop.put("logged-in", "2");
//identified via form-login
//TODO: this does not work for a static admin, yet.
}else if(post != null && post.containsKey("username") && post.containsKey("password")){
- //entry=sb.userDB.passwordAuth((String)post.get("username"), (String)post.get("password"), (String)header.get(httpHeader.CONNECTION_PROP_CLIENTIP, "xxxxxx"));
final String username=post.get("username");
final String password=post.get("password");
@@ -107,7 +107,7 @@ public class User{
cookie=sb.userDB.getAdminCookie();
if(entry != null || staticAdmin){
- final httpHeader outgoingHeader=new httpHeader();
+ final httpResponseHeader outgoingHeader=new httpResponseHeader();
outgoingHeader.setCookie("login", cookie);
prop.setOutgoingHeader(outgoingHeader);
@@ -144,12 +144,12 @@ public class User{
if(post!=null && post.containsKey("logout")){
prop.put("logged-in", "0");
if(entry != null){
- entry.logout(((String)header.get(httpHeader.CONNECTION_PROP_CLIENTIP, "xxxxxx")), userDB.getLoginToken(header.getHeaderCookies())); //todo: logout cookie
+ entry.logout(((String)requestHeader.get(httpRequestHeader.CONNECTION_PROP_CLIENTIP, "xxxxxx")), userDB.getLoginToken(requestHeader.getHeaderCookies())); //todo: logout cookie
}else{
- sb.userDB.adminLogout(userDB.getLoginToken(header.getHeaderCookies()));
+ sb.userDB.adminLogout(userDB.getLoginToken(requestHeader.getHeaderCookies()));
}
//XXX: This should not be needed anymore, because of isLoggedout
- if(! ((String) header.get(httpHeader.AUTHORIZATION, "xxxxxx")).equals("xxxxxx")){
+ if(! ((String) requestHeader.get(httpRequestHeader.AUTHORIZATION, "xxxxxx")).equals("xxxxxx")){
prop.put("AUTHENTICATE","admin log-in");
}
}
diff --git a/htroot/ViewFile.java b/htroot/ViewFile.java
index bd3d19f3b..a53b2b126 100644
--- a/htroot/ViewFile.java
+++ b/htroot/ViewFile.java
@@ -36,15 +36,15 @@ import java.util.Map;
import de.anomic.data.htmlTools;
import de.anomic.htmlFilter.htmlFilterImageEntry;
import de.anomic.http.HttpClient;
-import de.anomic.http.httpHeader;
-import de.anomic.http.httpdProxyCacheEntry;
+import de.anomic.http.httpRequestHeader;
+import de.anomic.http.httpResponseHeader;
+import de.anomic.index.indexDocumentMetadata;
import de.anomic.index.indexURLReference;
import de.anomic.plasma.plasmaCondenser;
import de.anomic.plasma.plasmaHTCache;
import de.anomic.plasma.plasmaParserDocument;
import de.anomic.plasma.plasmaSnippetCache;
import de.anomic.plasma.plasmaSwitchboard;
-import de.anomic.plasma.cache.IResourceInfo;
import de.anomic.plasma.parser.ParserException;
import de.anomic.server.serverFileUtils;
import de.anomic.server.serverObjects;
@@ -63,7 +63,7 @@ public class ViewFile {
private static final String HIGHLIGHT_CSS = "searchHighlight";
private static final int MAX_HIGHLIGHTS = 6;
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final serverObjects prop = new serverObjects();
final plasmaSwitchboard sb = (plasmaSwitchboard)env;
@@ -138,15 +138,21 @@ public class ViewFile {
// loading the resource content as byte array
InputStream resource = null;
long resourceLength = -1;
- IResourceInfo resInfo = null;
+ httpResponseHeader responseHeader = null;
String resMime = null;
// trying to load the resource body
resource = plasmaHTCache.getResourceContentStream(url);
resourceLength = plasmaHTCache.getResourceContentLength(url);
+ try {
+ responseHeader = plasmaHTCache.loadResponseHeader(url);
+ } catch (IllegalAccessException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
// if the resource body was not cached we try to load it from web
if (resource == null) {
- httpdProxyCacheEntry entry = null;
+ indexDocumentMetadata entry = null;
try {
entry = sb.crawlQueues.loadResourceFromWeb(url, 5000, false, true, false);
} catch (final Exception e) {
@@ -157,7 +163,6 @@ public class ViewFile {
}
if (entry != null) {
- resInfo = entry.getDocumentInfo();
resource = plasmaHTCache.getResourceContentStream(url);
resourceLength = plasmaHTCache.getResourceContentLength(url);
}
@@ -171,17 +176,17 @@ public class ViewFile {
}
// try to load resource metadata
- if (resInfo == null) {
+ if (responseHeader == null) {
// try to load the metadata from cache
try {
- resInfo = plasmaHTCache.loadResourceInfo(url);
+ responseHeader = plasmaHTCache.loadResponseHeader(url);
} catch (final Exception e) {
/* ignore this */
}
// if the metadata was not cached try to load it from web
- if (resInfo == null) {
+ if (responseHeader == null) {
final String protocol = url.getProtocol();
if (!((protocol.equals("http") || protocol.equals("https")))) {
prop.put("error", "6");
@@ -189,25 +194,17 @@ public class ViewFile {
return prop;
}
- final httpHeader responseHeader = HttpClient.whead(url.toString());
+ responseHeader = HttpClient.whead(url.toString());
if (responseHeader == null) {
prop.put("error", "4");
prop.put("error_errorText", "Unable to load resource metadata.");
prop.put("viewMode", VIEW_MODE_NO_TEXT);
return prop;
}
- try {
- resInfo = plasmaHTCache.getResourceInfoFactory().buildResourceInfoObj(url, responseHeader);
- } catch (final Exception e) {
- prop.put("error", "4");
- prop.putHTML("error_errorText", e.getMessage());
- prop.put("viewMode", VIEW_MODE_NO_TEXT);
- return prop;
- }
resMime = responseHeader.mime();
}
} else {
- resMime = resInfo.getMimeType();
+ resMime = responseHeader.mime();
}
final String[] wordArray = wordArray(post.get("words", null));
@@ -244,7 +241,7 @@ public class ViewFile {
// parsing the resource content
plasmaParserDocument document = null;
try {
- document = plasmaSnippetCache.parseDocument(url, resourceLength, resource, resInfo);
+ document = plasmaSnippetCache.parseDocument(url, resourceLength, resource);
if (document == null) {
prop.put("error", "5");
prop.put("error_errorText", "Unknown error");
diff --git a/htroot/ViewImage.java b/htroot/ViewImage.java
index fd479c221..569a5b71a 100644
--- a/htroot/ViewImage.java
+++ b/htroot/ViewImage.java
@@ -29,7 +29,7 @@ import java.io.InputStream;
import java.net.MalformedURLException;
import java.util.HashMap;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSnippetCache;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverFileUtils;
@@ -43,7 +43,7 @@ public class ViewImage {
private static HashMap<String, Image> iconcache = new HashMap<String, Image>();
private static String defaulticon = "htroot/env/grafics/dfltfvcn.ico";
- public static Image respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static Image respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final plasmaSwitchboard sb = (plasmaSwitchboard)env;
@@ -53,7 +53,7 @@ public class ViewImage {
String urlString = post.get("url", "");
final String urlLicense = post.get("code", "");
- final boolean auth = ((String) header.get(httpHeader.CONNECTION_PROP_CLIENTIP, "")).equals("localhost") || sb.verifyAuthentication(header, true); // handle access rights
+ final boolean auth = ((String) header.get(httpRequestHeader.CONNECTION_PROP_CLIENTIP, "")).equals("localhost") || sb.verifyAuthentication(header, true); // handle access rights
yacyURL url = null;
if ((urlString.length() > 0) && (auth)) try {
diff --git a/htroot/ViewLog_p.java b/htroot/ViewLog_p.java
index c258af025..ba97d86de 100644
--- a/htroot/ViewLog_p.java
+++ b/htroot/ViewLog_p.java
@@ -33,7 +33,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
import de.anomic.server.logging.GuiHandler;
@@ -41,7 +41,7 @@ import de.anomic.server.logging.LogalizerHandler;
public class ViewLog_p {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final serverObjects prop = new serverObjects();
String[] log = new String[0];
boolean reversed = false;
diff --git a/htroot/ViewProfile.java b/htroot/ViewProfile.java
index 2e17fe53c..2ddc83230 100644
--- a/htroot/ViewProfile.java
+++ b/htroot/ViewProfile.java
@@ -36,7 +36,7 @@ import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.kelondro.kelondroBase64Order;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
@@ -50,7 +50,7 @@ import de.anomic.yacy.yacySeed;
public class ViewProfile {
@SuppressWarnings("unchecked")
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch env) {
final serverObjects prop = new serverObjects();
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
final boolean authenticated = sb.adminAuthenticated(header) >= 2;
diff --git a/htroot/WatchCrawler_p.java b/htroot/WatchCrawler_p.java
index a107c77e4..551d3805c 100644
--- a/htroot/WatchCrawler_p.java
+++ b/htroot/WatchCrawler_p.java
@@ -45,7 +45,7 @@ import de.anomic.data.bookmarksDB;
import de.anomic.data.listManager;
import de.anomic.htmlFilter.htmlFilterContentScraper;
import de.anomic.htmlFilter.htmlFilterWriter;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.plasma.plasmaSwitchboardConstants;
import de.anomic.server.serverFileUtils;
@@ -64,7 +64,7 @@ public class WatchCrawler_p {
// this servlet does NOT create the WatchCrawler page content!
// this servlet starts a web crawl. The interface for entering the web crawl parameters is in IndexCreate_p.html
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
// return variable that accumulates replacements
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
// inital values for AJAX Elements (without JavaScript)
diff --git a/htroot/WatchWebStructure_p.java b/htroot/WatchWebStructure_p.java
index 81a104d02..16f2c7f33 100644
--- a/htroot/WatchWebStructure_p.java
+++ b/htroot/WatchWebStructure_p.java
@@ -2,7 +2,7 @@
import java.util.Iterator;
import de.anomic.crawler.CrawlProfile.entry;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.plasma.plasmaWordIndex;
import de.anomic.server.serverObjects;
@@ -10,7 +10,7 @@ import de.anomic.server.serverSwitch;
public class WatchWebStructure_p {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
final serverObjects prop = new serverObjects();
diff --git a/htroot/WebStructurePicture_p.java b/htroot/WebStructurePicture_p.java
index 2cf61153a..46b567370 100644
--- a/htroot/WebStructurePicture_p.java
+++ b/htroot/WebStructurePicture_p.java
@@ -30,7 +30,7 @@ import java.util.Date;
import java.util.Iterator;
import java.util.Map;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.kelondro.kelondroBase64Order;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.plasma.plasmaWebStructure;
@@ -45,7 +45,7 @@ public class WebStructurePicture_p {
private static final double maxlongd = Long.MAX_VALUE;
- public static ymageMatrix respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static ymageMatrix respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
int width = 768;
diff --git a/htroot/Wiki.java b/htroot/Wiki.java
index 33c99824f..b017aec9f 100644
--- a/htroot/Wiki.java
+++ b/htroot/Wiki.java
@@ -36,7 +36,7 @@ import java.util.Iterator;
import de.anomic.data.diff;
import de.anomic.data.wikiBoard;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
@@ -54,7 +54,7 @@ public class Wiki {
}
- public static serverObjects respond(final httpHeader header, serverObjects post, final serverSwitch<?> env) throws IOException {
+ public static serverObjects respond(final httpRequestHeader header, serverObjects post, final serverSwitch<?> env) throws IOException {
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
final serverObjects prop = new serverObjects();
if (post == null) {
@@ -68,7 +68,7 @@ public class Wiki {
String access = sb.getConfig("WikiAccess", "admin");
final String pagename = get(post, "page", "start");
- final String ip = get(post, httpHeader.CONNECTION_PROP_CLIENTIP, "127.0.0.1");
+ final String ip = get(post, httpRequestHeader.CONNECTION_PROP_CLIENTIP, "127.0.0.1");
String author = get(post, "author", "anonymous");
if (author.equals("anonymous")) {
author = wikiBoard.guessAuthor(ip);
diff --git a/htroot/WikiHelp.java b/htroot/WikiHelp.java
index 24751f394..86deb29c8 100644
--- a/htroot/WikiHelp.java
+++ b/htroot/WikiHelp.java
@@ -27,13 +27,13 @@
// javac -classpath .:../classes WikiHelp.java
// if the shell's current path is HTROOT
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
public class WikiHelp {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
//final plasmaSwitchboard sb = (plasmaSwitchboard) env;
final serverObjects prop = new serverObjects();
return prop;
diff --git a/htroot/YaCySearchPluginFF.java b/htroot/YaCySearchPluginFF.java
index 4c62c1063..910f69be9 100644
--- a/htroot/YaCySearchPluginFF.java
+++ b/htroot/YaCySearchPluginFF.java
@@ -24,7 +24,7 @@
//javac -classpath .:../Classes Status.java
//if the shell's current path is HTROOT
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
@@ -37,12 +37,12 @@ public class YaCySearchPluginFF {
* @param env the serverSwitch object holding all runtime-data
* @return the rewrite-properties for the template
*/
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
final serverObjects prop = new serverObjects();
// getting the http host header
- final String hostSocket = header.get(httpHeader.CONNECTION_PROP_HOST);
+ final String hostSocket = header.get(httpRequestHeader.CONNECTION_PROP_HOST);
String host = hostSocket;
int port = 80;
diff --git a/htroot/autoconfig.java b/htroot/autoconfig.java
index bbc25e605..86a30a406 100644
--- a/htroot/autoconfig.java
+++ b/htroot/autoconfig.java
@@ -24,7 +24,7 @@
//javac -classpath .:../Classes Status.java
//if the shell's current path is HTROOT
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
@@ -38,12 +38,12 @@ public class autoconfig {
* @param env the serverSwitch object holding all runtime-data
* @return the rewrite-properties for the template
*/
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final serverObjects prop = new serverObjects();
// getting the http host header
- final String hostSocket = header.get(httpHeader.CONNECTION_PROP_HOST);
+ final String hostSocket = header.get(httpRequestHeader.CONNECTION_PROP_HOST);
String host = hostSocket;
int port = 80;
diff --git a/htroot/imagetest.java b/htroot/imagetest.java
index 372061fda..fdb41d5c5 100644
--- a/htroot/imagetest.java
+++ b/htroot/imagetest.java
@@ -24,7 +24,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
import de.anomic.ymage.ymageMatrix;
@@ -32,7 +32,7 @@ import de.anomic.ymage.ymageToolPrint;
public class imagetest {
- public static ymageMatrix respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static ymageMatrix respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
/*
BufferedImage bi = new BufferedImage(640, 400, BufferedImage.TYPE_INT_RGB);
Graphics2D g = bi.createGraphics();
diff --git a/htroot/index.java b/htroot/index.java
index 47f97622f..e0d7cec9d 100644
--- a/htroot/index.java
+++ b/htroot/index.java
@@ -29,7 +29,7 @@
// if the shell's current path is HTROOT
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSearchQuery;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.plasma.plasmaSwitchboardConstants;
@@ -38,7 +38,7 @@ import de.anomic.server.serverSwitch;
public class index {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
final serverObjects prop = new serverObjects();
diff --git a/htroot/opensearchdescription.java b/htroot/opensearchdescription.java
index c83637d6b..7375db667 100644
--- a/htroot/opensearchdescription.java
+++ b/htroot/opensearchdescription.java
@@ -24,7 +24,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverCore;
import de.anomic.server.serverObjects;
@@ -32,7 +32,7 @@ import de.anomic.server.serverSwitch;
public class opensearchdescription {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
// generate message content for open search description
String promoteSearchPageGreeting = env.getConfig("promoteSearchPageGreeting", "");
diff --git a/htroot/osm.java b/htroot/osm.java
index 260afeedd..1044e1fab 100644
--- a/htroot/osm.java
+++ b/htroot/osm.java
@@ -1,6 +1,6 @@
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
import de.anomic.ymage.ymageMatrix;
@@ -8,7 +8,7 @@ import de.anomic.ymage.ymageOSM;
public class osm {
- public static ymageMatrix respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static ymageMatrix respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
int zoom = 10;
double lat = 47.968056d;
diff --git a/htroot/rct_p.java b/htroot/rct_p.java
index a68b44b7e..1beb73919 100644
--- a/htroot/rct_p.java
+++ b/htroot/rct_p.java
@@ -30,7 +30,7 @@ import java.text.ParseException;
import java.util.Date;
import java.util.Iterator;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverDate;
import de.anomic.server.serverObjects;
@@ -43,7 +43,7 @@ import de.anomic.yacy.yacyURL;
public class rct_p {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
// return variable that accumulates replacements
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
final serverObjects prop = new serverObjects();
diff --git a/htroot/robots.java b/htroot/robots.java
index 8385ee190..5900fb4a0 100644
--- a/htroot/robots.java
+++ b/htroot/robots.java
@@ -3,7 +3,7 @@
import java.io.File;
import java.util.ArrayList;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.http.httpdRobotsTxtConfig;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.plasma.plasmaSwitchboardConstants;
@@ -13,7 +13,7 @@ import de.anomic.server.servletProperties;
public class robots {
- public static servletProperties respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static servletProperties respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final servletProperties prop = new servletProperties();
final httpdRobotsTxtConfig rbc = ((plasmaSwitchboard)env).robotstxtConfig;
diff --git a/htroot/sharedBlacklist_p.java b/htroot/sharedBlacklist_p.java
index caaccf0b4..e19c26313 100644
--- a/htroot/sharedBlacklist_p.java
+++ b/htroot/sharedBlacklist_p.java
@@ -39,7 +39,7 @@ import java.util.HashSet;
import de.anomic.crawler.HTTPLoader;
import de.anomic.data.listManager;
import de.anomic.http.HttpClient;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.index.indexAbstractReferenceBlacklist;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
@@ -57,7 +57,7 @@ public class sharedBlacklist_p {
public static final int STATUS_URL_PROBLEM = 4;
public static final int STATUS_WRONG_INVOCATION = 5;
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
// return variable that accumulates replacements
final serverObjects prop = new serverObjects();
@@ -107,10 +107,10 @@ public class sharedBlacklist_p {
if (downloadURL != null) {
// download the blacklist
try {
- final httpHeader reqHeader = new httpHeader();
- reqHeader.put(httpHeader.PRAGMA,"no-cache");
- reqHeader.put(httpHeader.CACHE_CONTROL,"no-cache");
- reqHeader.put(httpHeader.USER_AGENT, HTTPLoader.yacyUserAgent);
+ final httpRequestHeader reqHeader = new httpRequestHeader();
+ reqHeader.put(httpRequestHeader.PRAGMA,"no-cache");
+ reqHeader.put(httpRequestHeader.CACHE_CONTROL,"no-cache");
+ reqHeader.put(httpRequestHeader.USER_AGENT, HTTPLoader.yacyUserAgent);
// get List
final yacyURL u = new yacyURL(downloadURL, null);
@@ -130,8 +130,8 @@ public class sharedBlacklist_p {
try {
final yacyURL u = new yacyURL(downloadURL, null);
- final httpHeader reqHeader = new httpHeader();
- reqHeader.put(httpHeader.USER_AGENT, HTTPLoader.yacyUserAgent);
+ final httpRequestHeader reqHeader = new httpRequestHeader();
+ reqHeader.put(httpRequestHeader.USER_AGENT, HTTPLoader.yacyUserAgent);
otherBlacklist = nxTools.strings(HttpClient.wget(u.toString(), reqHeader, 10000), "UTF-8"); //get List
} catch (final Exception e) {
prop.put("status", STATUS_URL_PROBLEM);
diff --git a/htroot/ssitestservlet.java b/htroot/ssitestservlet.java
index ec8f77b3d..a42271769 100644
--- a/htroot/ssitestservlet.java
+++ b/htroot/ssitestservlet.java
@@ -25,13 +25,13 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
public class ssitestservlet {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
//plasmaSwitchboard sb = (plasmaSwitchboard) env;
final serverObjects prop = new serverObjects();
diff --git a/htroot/test.java b/htroot/test.java
index 4c1398dc6..632817e30 100644
--- a/htroot/test.java
+++ b/htroot/test.java
@@ -1,4 +1,4 @@
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
@@ -6,7 +6,7 @@ public class test {
// http://localhost:8080/test.xml?count=10
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final serverObjects prop = new serverObjects();
final int count = Math.min(1000, (post == null) ? 0 : post.getInt("count", 0));
diff --git a/htroot/www/welcome.java b/htroot/www/welcome.java
index e443c95e6..ebbe3b592 100644
--- a/htroot/www/welcome.java
+++ b/htroot/www/welcome.java
@@ -32,7 +32,7 @@ import java.io.File;
import java.net.InetAddress;
import java.net.UnknownHostException;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverCore;
import de.anomic.server.serverDomains;
@@ -42,7 +42,7 @@ import de.anomic.yacy.yacySeed;
public class welcome {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
// return variable that accumulates replacements
@@ -61,7 +61,7 @@ public class welcome {
prop.put("hostip", "Unknown Host Exception");
}
prop.put("port", serverCore.getPortNr(env.getConfig("port","8080")));
- prop.put("clientip", (String) header.get(httpHeader.CONNECTION_PROP_CLIENTIP, ""));
+ prop.put("clientip", (String) header.get(httpRequestHeader.CONNECTION_PROP_CLIENTIP, ""));
final String peertype = (sb.webIndex.seedDB.mySeed() == null) ? yacySeed.PEERTYPE_JUNIOR : sb.webIndex.seedDB.mySeed().get(yacySeed.PEERTYPE, yacySeed.PEERTYPE_VIRGIN);
final boolean senior = (peertype.equals(yacySeed.PEERTYPE_SENIOR)) || (peertype.equals(yacySeed.PEERTYPE_PRINCIPAL));
diff --git a/htroot/xml/blacklists_p.java b/htroot/xml/blacklists_p.java
index fee690ade..aed2d7fe2 100644
--- a/htroot/xml/blacklists_p.java
+++ b/htroot/xml/blacklists_p.java
@@ -23,7 +23,7 @@ import java.io.File;
import java.util.ArrayList;
import de.anomic.data.listManager;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.index.indexAbstractReferenceBlacklist;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
@@ -31,7 +31,7 @@ import de.anomic.server.serverSwitch;
public class blacklists_p {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final serverObjects prop = new serverObjects();
listManager.listsPath = new File(listManager.switchboard.getRootPath(),listManager.switchboard.getConfig("listManager.listsPath", "DATA/LISTS"));
diff --git a/htroot/xml/bookmarks/posts/all.java b/htroot/xml/bookmarks/posts/all.java
index 1aa49340a..d39133d48 100644
--- a/htroot/xml/bookmarks/posts/all.java
+++ b/htroot/xml/bookmarks/posts/all.java
@@ -30,7 +30,7 @@ import java.util.Date;
import java.util.Iterator;
import de.anomic.data.bookmarksDB;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverCodings;
import de.anomic.server.serverDate;
@@ -38,7 +38,7 @@ import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
public class all {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
// return variable that accumulates replacements
final plasmaSwitchboard switchboard = (plasmaSwitchboard) env;
final boolean isAdmin=switchboard.verifyAuthentication(header, true);
diff --git a/htroot/xml/bookmarks/posts/delete_p.java b/htroot/xml/bookmarks/posts/delete_p.java
index 256b07d6b..8f1a29969 100644
--- a/htroot/xml/bookmarks/posts/delete_p.java
+++ b/htroot/xml/bookmarks/posts/delete_p.java
@@ -25,14 +25,14 @@
package xml.bookmarks.posts;
import java.net.MalformedURLException;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
import de.anomic.yacy.yacyURL;
public class delete_p {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
// return variable that accumulates replacements
final plasmaSwitchboard switchboard = (plasmaSwitchboard) env;
final serverObjects prop = new serverObjects();
diff --git a/htroot/xml/bookmarks/posts/get.java b/htroot/xml/bookmarks/posts/get.java
index 49d011e0b..4e5a68e51 100644
--- a/htroot/xml/bookmarks/posts/get.java
+++ b/htroot/xml/bookmarks/posts/get.java
@@ -25,7 +25,7 @@ import java.util.Date;
import java.util.Iterator;
import de.anomic.data.bookmarksDB;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverCodings;
import de.anomic.server.serverDate;
@@ -33,7 +33,7 @@ import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
public class get {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
// return variable that accumulates replacements
final plasmaSwitchboard switchboard = (plasmaSwitchboard) env;
final boolean isAdmin=switchboard.verifyAuthentication(header, true);
diff --git a/htroot/xml/bookmarks/tags/get.java b/htroot/xml/bookmarks/tags/get.java
index ac42a14cd..7f7360ab9 100644
--- a/htroot/xml/bookmarks/tags/get.java
+++ b/htroot/xml/bookmarks/tags/get.java
@@ -32,7 +32,7 @@ import java.util.Iterator;
import de.anomic.data.bookmarksDB;
import de.anomic.data.bookmarksDB.Tag;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
@@ -42,7 +42,7 @@ public class get {
final static int SORT_SIZE = 2;
final static int SHOW_ALL = -1;
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
// return variable that accumulates replacements
final plasmaSwitchboard switchboard = (plasmaSwitchboard) env;
final boolean isAdmin=switchboard.verifyAuthentication(header, true);
diff --git a/htroot/xml/bookmarks/tags/rename_p.java b/htroot/xml/bookmarks/tags/rename_p.java
index 1a640626c..8c60cbb4f 100644
--- a/htroot/xml/bookmarks/tags/rename_p.java
+++ b/htroot/xml/bookmarks/tags/rename_p.java
@@ -27,13 +27,13 @@
//package xml.bookmarks.tags;
package xml.bookmarks.tags;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
public class rename_p {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
// return variable that accumulates replacements
final plasmaSwitchboard switchboard = (plasmaSwitchboard) env;
final serverObjects prop = new serverObjects();
diff --git a/htroot/xml/bookmarks/xbel/xbel.java b/htroot/xml/bookmarks/xbel/xbel.java
index a365544eb..8f83b6279 100644
--- a/htroot/xml/bookmarks/xbel/xbel.java
+++ b/htroot/xml/bookmarks/xbel/xbel.java
@@ -5,7 +5,7 @@ import java.util.Iterator;
import de.anomic.data.bookmarksDB;
import de.anomic.data.htmlTools;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverDate;
import de.anomic.server.serverObjects;
@@ -17,7 +17,7 @@ public class xbel {
private static plasmaSwitchboard switchboard = null;
private static boolean isAdmin = false;
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
int count = 0;;
diff --git a/htroot/xml/config_p.java b/htroot/xml/config_p.java
index 7df3c75a8..17c78a8bd 100644
--- a/htroot/xml/config_p.java
+++ b/htroot/xml/config_p.java
@@ -27,14 +27,14 @@ import java.util.Collections;
import java.util.Iterator;
import java.util.List;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
public class config_p {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
// return variable that accumulates replacements
//plasmaSwitchboard switchboard = (plasmaSwitchboard) env;
final serverObjects prop = new serverObjects();
diff --git a/htroot/xml/feed.java b/htroot/xml/feed.java
index 31a801192..01194a66a 100755
--- a/htroot/xml/feed.java
+++ b/htroot/xml/feed.java
@@ -26,7 +26,7 @@
package xml;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
@@ -35,7 +35,7 @@ import de.anomic.xml.RSSMessage;
public class feed {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
// insert default values
diff --git a/htroot/xml/queues_p.java b/htroot/xml/queues_p.java
index cabd2bf9f..b2ccfc0e5 100644
--- a/htroot/xml/queues_p.java
+++ b/htroot/xml/queues_p.java
@@ -37,7 +37,7 @@ import java.util.Locale;
import de.anomic.crawler.CrawlEntry;
import de.anomic.crawler.IndexingStack;
import de.anomic.crawler.NoticedURL;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.plasma.plasmaSwitchboardConstants;
import de.anomic.server.serverObjects;
@@ -55,7 +55,7 @@ public class queues_p {
return dayFormatter.format(date);
}
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
// return variable that accumulates replacements
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
//wikiCode wikiTransformer = new wikiCode(switchboard);
diff --git a/htroot/xml/status_p.java b/htroot/xml/status_p.java
index a76997a87..6af88171d 100644
--- a/htroot/xml/status_p.java
+++ b/htroot/xml/status_p.java
@@ -20,7 +20,8 @@
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
package xml;
-import de.anomic.http.httpHeader;
+
+import de.anomic.http.httpRequestHeader;
import de.anomic.http.httpdByteCountInputStream;
import de.anomic.http.httpdByteCountOutputStream;
import de.anomic.plasma.plasmaSwitchboard;
@@ -33,7 +34,7 @@ import de.anomic.server.serverSwitch;
public class status_p {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
// return variable that accumulates replacements
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
final serverObjects prop = new serverObjects();
diff --git a/htroot/xml/util/getpageinfo_p.java b/htroot/xml/util/getpageinfo_p.java
index fe36e3c65..c27ca9acc 100644
--- a/htroot/xml/util/getpageinfo_p.java
+++ b/htroot/xml/util/getpageinfo_p.java
@@ -34,7 +34,7 @@ import de.anomic.crawler.HTTPLoader;
import de.anomic.htmlFilter.htmlFilterContentScraper;
import de.anomic.htmlFilter.htmlFilterWriter;
import de.anomic.http.HttpClient;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverFileUtils;
import de.anomic.server.serverObjects;
@@ -43,7 +43,7 @@ import de.anomic.yacy.yacyURL;
public class getpageinfo_p {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
final serverObjects prop = new serverObjects();
prop.put("sitemap", "");
@@ -65,8 +65,8 @@ public class getpageinfo_p {
if (actions.indexOf("title")>=0) {
try {
final yacyURL u = new yacyURL(url, null);
- final httpHeader reqHeader = new httpHeader();
- reqHeader.put(httpHeader.USER_AGENT, HTTPLoader.yacyUserAgent); // do not set the crawler user agent, because this page was loaded by manual entering of the url
+ final httpRequestHeader reqHeader = new httpRequestHeader();
+ reqHeader.put(httpRequestHeader.USER_AGENT, HTTPLoader.yacyUserAgent); // do not set the crawler user agent, because this page was loaded by manual entering of the url
final byte[] r = HttpClient.wget(u.toString(), reqHeader, 5000);
if (r == null) return prop;
final String contentString=new String(r);
diff --git a/htroot/xml/util/ynetSearch.java b/htroot/xml/util/ynetSearch.java
index 76a8b4e1d..f227394cb 100644
--- a/htroot/xml/util/ynetSearch.java
+++ b/htroot/xml/util/ynetSearch.java
@@ -30,14 +30,14 @@ import java.io.InputStream;
import java.net.URL;
import java.util.Scanner;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
public class ynetSearch {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final plasmaSwitchboard switchboard = (plasmaSwitchboard) env;
final boolean isAdmin=switchboard.verifyAuthentication(header, true);
final serverObjects prop = new serverObjects();
diff --git a/htroot/xml/version.java b/htroot/xml/version.java
index 63440b032..3df6f30bc 100644
--- a/htroot/xml/version.java
+++ b/htroot/xml/version.java
@@ -20,16 +20,15 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 US
-
package xml;
-import de.anomic.http.httpHeader;
+
+import de.anomic.http.httpRequestHeader;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
public class version {
-
-
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
// return variable that accumulates replacements
final serverObjects prop = new serverObjects();
diff --git a/htroot/xml/webstructure.java b/htroot/xml/webstructure.java
index 0af438e60..20a0fbcf1 100644
--- a/htroot/xml/webstructure.java
+++ b/htroot/xml/webstructure.java
@@ -30,7 +30,7 @@ package xml;
import java.util.Iterator;
import java.util.Map;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.plasma.plasmaWebStructure;
import de.anomic.server.serverObjects;
@@ -38,7 +38,7 @@ import de.anomic.server.serverSwitch;
public class webstructure {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final serverObjects prop = new serverObjects();
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
final boolean latest = ((post == null) ? false : post.containsKey("latest"));
diff --git a/htroot/yacy/crawlReceipt.java b/htroot/yacy/crawlReceipt.java
index aa5ed1ec0..8d7997d33 100644
--- a/htroot/yacy/crawlReceipt.java
+++ b/htroot/yacy/crawlReceipt.java
@@ -30,7 +30,7 @@
import java.io.IOException;
import de.anomic.crawler.ZURL;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.index.indexURLReference;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
@@ -47,7 +47,7 @@ public final class crawlReceipt {
* this is used to respond on a remote crawling request
*/
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
// return variable that accumulates replacements
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
final serverObjects prop = new serverObjects();
diff --git a/htroot/yacy/hello.java b/htroot/yacy/hello.java
index 518425795..8f7e68c1b 100644
--- a/htroot/yacy/hello.java
+++ b/htroot/yacy/hello.java
@@ -32,7 +32,7 @@ import java.util.ConcurrentModificationException;
import java.util.Iterator;
import java.util.Map;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverCore;
import de.anomic.server.serverDomains;
@@ -49,7 +49,7 @@ public final class hello {
// example:
// http://localhost:8080/yacy/hello.html?count=1&seed=p|{Hash=sCJ6Tq8T0N9x,IPType=&empty;,Port=8080,IP=,Uptime=8,rI=190,Version=0.10004882,PeerType=junior,UTC=+0200,RCount=0,sI=0,LastSeen=20080605103333,Name=intratest,CCount=5.0,SCount=40,news=,USpeed=0,CRTCnt=0,CRWCnt=0,BDate=20080605081349,rU=190,LCount=187,dct=1212668923654,ICount=2,sU=0,ISpeed=0,RSpeed=0.0,NCount=0,Flags=oooo}
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) throws InterruptedException {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) throws InterruptedException {
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
final serverObjects prop = new serverObjects();
prop.put("message", "none");
@@ -70,7 +70,7 @@ public final class hello {
int count = 0;
try {count = (countStr == null) ? 0 : Integer.parseInt(countStr);} catch (final NumberFormatException e) {count = 0;}
// final Date remoteTime = yacyCore.parseUniversalDate((String) post.get(MYTIME)); // read remote time
- final String clientip = (String) header.get(httpHeader.CONNECTION_PROP_CLIENTIP, "<unknown>"); // read an artificial header addendum
+ final String clientip = (String) header.get(httpRequestHeader.CONNECTION_PROP_CLIENTIP, "<unknown>"); // read an artificial header addendum
final InetAddress ias = serverDomains.dnsResolve(clientip);
if (ias == null) {
prop.put("message", "cannot resolve your IP from your reported location " + clientip);
@@ -94,7 +94,7 @@ public final class hello {
// if ((properTest != null) && (! properTest.substring(0,1).equals("IP"))) { return null; }
// we easily know the caller's IP:
- final String userAgent = (String) header.get(httpHeader.USER_AGENT, "<unknown>");
+ final String userAgent = (String) header.get(httpRequestHeader.USER_AGENT, "<unknown>");
final String reportedip = remoteSeed.getIP();
final String reportedPeerType = remoteSeed.get(yacySeed.PEERTYPE, yacySeed.PEERTYPE_JUNIOR);
final float clientversion = remoteSeed.getVersion();
diff --git a/htroot/yacy/list.java b/htroot/yacy/list.java
index e1ccdb6d4..8bec85177 100644
--- a/htroot/yacy/list.java
+++ b/htroot/yacy/list.java
@@ -29,7 +29,7 @@
import java.io.File;
import de.anomic.data.listManager;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.plasma.plasmaSwitchboardConstants;
import de.anomic.server.serverCore;
@@ -41,7 +41,7 @@ import de.anomic.yacy.yacySeed;
public final class list {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
if (post == null || env == null) throw new NullPointerException("post: " + post + ", sb: " + env);
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
@@ -58,7 +58,7 @@ public final class list {
final yacySeed bla = sb.webIndex.seedDB.get(post.get("iam", ""));
if (bla != null) otherPeerName = bla.getName();
}
- if (otherPeerName == null) otherPeerName = header.get(httpHeader.CONNECTION_PROP_CLIENTIP);
+ if (otherPeerName == null) otherPeerName = header.get(httpRequestHeader.CONNECTION_PROP_CLIENTIP);
if ((sb.isRobinsonMode()) && (!sb.isInMyCluster(otherPeerName))) {
// if we are a robinson cluster, answer only if this client is known by our network definition
diff --git a/htroot/yacy/message.java b/htroot/yacy/message.java
index 813174070..9802ccffa 100644
--- a/htroot/yacy/message.java
+++ b/htroot/yacy/message.java
@@ -35,7 +35,7 @@ import java.text.SimpleDateFormat;
import java.util.Date;
import de.anomic.data.messageBoard;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverFileUtils;
import de.anomic.server.serverObjects;
@@ -53,7 +53,7 @@ public final class message {
return SimpleFormatter.format(date);
}
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
if (post == null || env == null) { return null; }
// return variable that accumulates replacements
@@ -81,7 +81,7 @@ public final class message {
if ((sb.isRobinsonMode()) &&
(!((sb.isPublicRobinson()) ||
- (sb.isInMyCluster(header.get(httpHeader.CONNECTION_PROP_CLIENTIP)))))) {
+ (sb.isInMyCluster(header.get(httpRequestHeader.CONNECTION_PROP_CLIENTIP)))))) {
// if we are a robinson cluster, answer only if this client is known by our network definition
prop.put("response", "-1"); // request rejected
return prop;
diff --git a/htroot/yacy/profile.java b/htroot/yacy/profile.java
index 498efc878..272a9fff4 100644
--- a/htroot/yacy/profile.java
+++ b/htroot/yacy/profile.java
@@ -35,7 +35,7 @@ import java.io.IOException;
import java.util.Iterator;
import java.util.Properties;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
@@ -43,7 +43,7 @@ import de.anomic.yacy.yacyNetwork;
public final class profile {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
// return variable that accumulates replacements
final serverObjects prop = new serverObjects();
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
@@ -52,7 +52,7 @@ public final class profile {
if ((sb.isRobinsonMode()) &&
(!sb.isPublicRobinson()) &&
- (!sb.isInMyCluster(header.get(httpHeader.CONNECTION_PROP_CLIENTIP)))) {
+ (!sb.isInMyCluster(header.get(httpRequestHeader.CONNECTION_PROP_CLIENTIP)))) {
// if we are a robinson cluster, answer only if this client is known by our network definition
prop.put("list", "0");
return prop;
diff --git a/htroot/yacy/query.java b/htroot/yacy/query.java
index d91b7b41e..a339227b3 100644
--- a/htroot/yacy/query.java
+++ b/htroot/yacy/query.java
@@ -27,7 +27,7 @@
// javac -classpath .:../../classes query.java
// if the shell's current path is HTROOT
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverDate;
import de.anomic.server.serverObjects;
@@ -39,7 +39,7 @@ public final class query {
// example:
// http://localhost:8080/yacy/query.html?youare=sCJ6Tq8T0N9x&object=lurlcount
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> ss) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> ss) {
if (post == null || ss == null) { return null; }
// return variable that accumulates replacements
@@ -52,7 +52,7 @@ public final class query {
if ((sb.isRobinsonMode()) &&
(!sb.isPublicRobinson()) &&
- (!sb.isInMyCluster(header.get(httpHeader.CONNECTION_PROP_CLIENTIP)))) {
+ (!sb.isInMyCluster(header.get(httpRequestHeader.CONNECTION_PROP_CLIENTIP)))) {
// if we are a robinson cluster, answer only if we are public robinson peers,
// or we are a private cluster and the requester is in our cluster.
// if we don't answer, the remote peer will recognize us as junior peer,
diff --git a/htroot/yacy/search.java b/htroot/yacy/search.java
index 47570f1d6..5ad00c3f2 100644
--- a/htroot/yacy/search.java
+++ b/htroot/yacy/search.java
@@ -34,7 +34,7 @@ import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.index.indexContainer;
import de.anomic.kelondro.kelondroBase64Order;
import de.anomic.kelondro.kelondroBitfield;
@@ -60,7 +60,7 @@ import de.anomic.yacy.yacyURL;
public final class search {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
// return variable that accumulates replacements
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
sb.remoteSearchLastAccess = System.currentTimeMillis();
@@ -68,7 +68,7 @@ public final class search {
final serverObjects prop = new serverObjects();
if ((post == null) || (env == null)) return prop;
if (!yacyNetwork.authentifyRequest(post, env)) return prop;
- final String client = header.get(httpHeader.CONNECTION_PROP_CLIENTIP);
+ final String client = header.get(httpRequestHeader.CONNECTION_PROP_CLIENTIP);
//System.out.println("yacy: search received request = " + post.toString());
@@ -113,7 +113,7 @@ public final class search {
if ((sb.isRobinsonMode()) &&
(!((sb.isPublicRobinson()) ||
- (sb.isInMyCluster(header.get(httpHeader.CONNECTION_PROP_CLIENTIP)))))) {
+ (sb.isInMyCluster(header.get(httpRequestHeader.CONNECTION_PROP_CLIENTIP)))))) {
// if we are a robinson cluster, answer only if this client is known by our network definition
prop.put("links", "");
prop.put("linkcount", "0");
diff --git a/htroot/yacy/transfer.java b/htroot/yacy/transfer.java
index 2c91db4b5..56357c0fa 100644
--- a/htroot/yacy/transfer.java
+++ b/htroot/yacy/transfer.java
@@ -27,7 +27,7 @@
import java.io.File;
import java.io.IOException;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.kelondro.kelondroBase64Order;
import de.anomic.plasma.plasmaRankingDistribution;
import de.anomic.plasma.plasmaSwitchboard;
@@ -40,7 +40,7 @@ import de.anomic.yacy.yacySeed;
public final class transfer {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
final serverObjects prop = new serverObjects();
if ((post == null) || (env == null)) return prop;
@@ -70,8 +70,8 @@ public final class transfer {
if ((otherseed == null) || (filename.indexOf("..") >= 0)) {
// reject unknown peers: this does not appear fair, but anonymous senders are dangerous
// reject paths that contain '..' because they are dangerous
- if (otherseed == null) sb.getLog().logFine("RankingTransmission: rejected unknown peer '" + otherpeer + "', current IP " + header.get(httpHeader.CONNECTION_PROP_CLIENTIP, "unknown"));
- if (filename.indexOf("..") >= 0) sb.getLog().logFine("RankingTransmission: rejected wrong path '" + filename + "' from peer " + (otherseed == null ? "null" : otherseed.getName() + "/" + otherseed.getPublicAddress()) + ", current IP " + header.get(httpHeader.CONNECTION_PROP_CLIENTIP, "unknown"));
+ if (otherseed == null) sb.getLog().logFine("RankingTransmission: rejected unknown peer '" + otherpeer + "', current IP " + header.get(httpRequestHeader.CONNECTION_PROP_CLIENTIP, "unknown"));
+ if (filename.indexOf("..") >= 0) sb.getLog().logFine("RankingTransmission: rejected wrong path '" + filename + "' from peer " + (otherseed == null ? "null" : otherseed.getName() + "/" + otherseed.getPublicAddress()) + ", current IP " + header.get(httpRequestHeader.CONNECTION_PROP_CLIENTIP, "unknown"));
return prop;
}
diff --git a/htroot/yacy/transferRWI.java b/htroot/yacy/transferRWI.java
index fbf64ac00..3ea046c4e 100644
--- a/htroot/yacy/transferRWI.java
+++ b/htroot/yacy/transferRWI.java
@@ -31,7 +31,7 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.index.indexRWIRowEntry;
import de.anomic.index.indexReferenceBlacklist;
import de.anomic.plasma.plasmaSwitchboard;
@@ -48,7 +48,7 @@ import de.anomic.yacy.yacySeed;
public final class transferRWI {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) throws InterruptedException {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) throws InterruptedException {
// return variable that accumulates replacements
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
diff --git a/htroot/yacy/transferURL.java b/htroot/yacy/transferURL.java
index 0fba80c53..fec91b9b7 100644
--- a/htroot/yacy/transferURL.java
+++ b/htroot/yacy/transferURL.java
@@ -29,7 +29,7 @@
import java.io.IOException;
import java.text.ParseException;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.index.indexReferenceBlacklist;
import de.anomic.index.indexURLReference;
import de.anomic.plasma.plasmaSwitchboard;
@@ -46,7 +46,7 @@ import de.anomic.yacy.yacySeed;
public final class transferURL {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) throws InterruptedException {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) throws InterruptedException {
final long start = System.currentTimeMillis();
long freshdate = 0;
try {freshdate = serverDate.parseShortDay("20061101").getTime();} catch (final ParseException e1) {}
diff --git a/htroot/yacy/urls.java b/htroot/yacy/urls.java
index 6268b61cf..ba9af1916 100644
--- a/htroot/yacy/urls.java
+++ b/htroot/yacy/urls.java
@@ -29,7 +29,7 @@ import java.util.Date;
import de.anomic.crawler.CrawlEntry;
import de.anomic.crawler.NoticedURL;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.index.indexURLReference;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverDate;
@@ -40,7 +40,7 @@ import de.anomic.yacy.yacyURL;
public class urls {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
// insert default values
diff --git a/htroot/yacy/user/sidebar_history.java b/htroot/yacy/user/sidebar_history.java
index c1096ce14..b733abec5 100644
--- a/htroot/yacy/user/sidebar_history.java
+++ b/htroot/yacy/user/sidebar_history.java
@@ -27,7 +27,7 @@
import java.util.HashSet;
import java.util.Iterator;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSearchQuery;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
@@ -35,13 +35,13 @@ import de.anomic.server.serverSwitch;
public class sidebar_history {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
final serverObjects prop = new serverObjects();
// list search history
final Iterator<plasmaSearchQuery> i = sb.localSearches.iterator();
- final String client = header.get(httpHeader.CONNECTION_PROP_CLIENTIP);
+ final String client = header.get(httpRequestHeader.CONNECTION_PROP_CLIENTIP);
plasmaSearchQuery query;
int c = 0;
final HashSet<String> visibleQueries = new HashSet<String>();
diff --git a/htroot/yacy/user/sidebar_navigation.java b/htroot/yacy/user/sidebar_navigation.java
index 56c44d48c..3473ca66f 100644
--- a/htroot/yacy/user/sidebar_navigation.java
+++ b/htroot/yacy/user/sidebar_navigation.java
@@ -28,7 +28,7 @@ import java.util.Iterator;
import java.util.Set;
import java.util.TreeSet;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.kelondro.kelondroMSetTools;
import de.anomic.kelondro.kelondroNaturalOrder;
import de.anomic.plasma.plasmaSearchEvent;
@@ -42,7 +42,7 @@ public class sidebar_navigation {
private static final int MAX_TOPWORDS = 24;
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final serverObjects prop = new serverObjects();
final String eventID = post.get("eventID", "");
diff --git a/htroot/yacy/user/ysearch.java b/htroot/yacy/user/ysearch.java
index ccff5e5ee..7ba6061a2 100644
--- a/htroot/yacy/user/ysearch.java
+++ b/htroot/yacy/user/ysearch.java
@@ -26,7 +26,7 @@
import java.util.TreeSet;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.index.indexWord;
import de.anomic.kelondro.kelondroBitfield;
import de.anomic.kelondro.kelondroMSetTools;
@@ -50,7 +50,7 @@ import de.anomic.yacy.yacyURL;
*/
public class ysearch {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
sb.localSearchLastAccess = System.currentTimeMillis();
@@ -62,7 +62,7 @@ public class ysearch {
String promoteSearchPageGreeting = env.getConfig("promoteSearchPageGreeting", "");
if (env.getConfigBool("promoteSearchPageGreeting.useNetworkName", false)) promoteSearchPageGreeting = env.getConfig("network.unit.description", "");
if (promoteSearchPageGreeting.length() == 0) promoteSearchPageGreeting = "P2P WEB SEARCH";
- final String client = header.get(httpHeader.CONNECTION_PROP_CLIENTIP); // the search client who initiated the search
+ final String client = header.get(httpRequestHeader.CONNECTION_PROP_CLIENTIP); // the search client who initiated the search
// get query
String querystring = (post == null) ? "" : post.get("search", "").trim();
diff --git a/htroot/yacy/user/ysearchitem.java b/htroot/yacy/user/ysearchitem.java
index 41535edc0..27ae6952e 100644
--- a/htroot/yacy/user/ysearchitem.java
+++ b/htroot/yacy/user/ysearchitem.java
@@ -30,7 +30,7 @@ import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.TreeSet;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSearchEvent;
import de.anomic.plasma.plasmaSearchQuery;
import de.anomic.plasma.plasmaSearchRankingProcess;
@@ -49,14 +49,14 @@ public class ysearchitem {
private static final int namelength = 60;
private static final int urllength = 120;
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
final serverObjects prop = new serverObjects();
final String eventID = post.get("eventID", "");
final boolean rss = post.get("rss", "false").equals("true");
final int item = post.getInt("item", -1);
- final boolean auth = ((String) header.get(httpHeader.CONNECTION_PROP_CLIENTIP, "")).equals("localhost") || sb.verifyAuthentication(header, true);
+ final boolean auth = ((String) header.get(httpRequestHeader.CONNECTION_PROP_CLIENTIP, "")).equals("localhost") || sb.verifyAuthentication(header, true);
// default settings for blank item
prop.put("content", "0");
diff --git a/htroot/yacysearch.java b/htroot/yacysearch.java
index a3883cb0c..313efe3c4 100644
--- a/htroot/yacysearch.java
+++ b/htroot/yacysearch.java
@@ -30,7 +30,7 @@
import java.util.HashMap;
import java.util.TreeSet;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.index.indexURLReference;
import de.anomic.index.indexWord;
import de.anomic.kelondro.kelondroBitfield;
@@ -59,7 +59,7 @@ import de.anomic.yacy.yacyURL;
public class yacysearch {
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
sb.localSearchLastAccess = System.currentTimeMillis();
@@ -72,7 +72,7 @@ public class yacysearch {
String promoteSearchPageGreeting = env.getConfig("promoteSearchPageGreeting", "");
if (env.getConfigBool("promoteSearchPageGreeting.useNetworkName", false)) promoteSearchPageGreeting = env.getConfig("network.unit.description", "");
if (promoteSearchPageGreeting.length() == 0) promoteSearchPageGreeting = "P2P Web Search";
- final String client = header.get(httpHeader.CONNECTION_PROP_CLIENTIP); // the search client who initiated the search
+ final String client = header.get(httpRequestHeader.CONNECTION_PROP_CLIENTIP); // the search client who initiated the search
// get query
String querystring = (post == null) ? "" : post.get("query", post.get("search", "")).trim(); // SRU compliance
diff --git a/htroot/yacysearchitem.java b/htroot/yacysearchitem.java
index 38e63ccfc..26684d7d1 100644
--- a/htroot/yacysearchitem.java
+++ b/htroot/yacysearchitem.java
@@ -32,7 +32,7 @@ import java.util.Iterator;
import java.util.Set;
import java.util.TreeSet;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.kelondro.kelondroMSetTools;
import de.anomic.kelondro.kelondroNaturalOrder;
import de.anomic.plasma.plasmaProfiling;
@@ -59,7 +59,7 @@ public class yacysearchitem {
private static final int urllength = 120;
private static final int MAX_TOPWORDS = 24;
- public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
final serverObjects prop = new serverObjects();
@@ -68,7 +68,7 @@ public class yacysearchitem {
final boolean rss = post.get("rss", "false").equals("true");
final boolean authenticated = sb.adminAuthenticated(header) >= 2;
final int item = post.getInt("item", -1);
- final boolean auth = ((String) header.get(httpHeader.CONNECTION_PROP_CLIENTIP, "")).equals("localhost") || sb.verifyAuthentication(header, true);
+ final boolean auth = ((String) header.get(httpRequestHeader.CONNECTION_PROP_CLIENTIP, "")).equals("localhost") || sb.verifyAuthentication(header, true);
// default settings for blank item
prop.put("content", "0");
diff --git a/source/de/anomic/crawler/CrawlQueues.java b/source/de/anomic/crawler/CrawlQueues.java
index 73e4a259f..b02da3178 100644
--- a/source/de/anomic/crawler/CrawlQueues.java
+++ b/source/de/anomic/crawler/CrawlQueues.java
@@ -36,7 +36,7 @@ import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-import de.anomic.http.httpdProxyCacheEntry;
+import de.anomic.index.indexDocumentMetadata;
import de.anomic.kelondro.kelondroFlexWidthArray;
import de.anomic.plasma.plasmaParser;
import de.anomic.plasma.plasmaSwitchboard;
@@ -465,7 +465,7 @@ public class CrawlQueues {
return;
}
- public httpdProxyCacheEntry loadResourceFromWeb(
+ public indexDocumentMetadata loadResourceFromWeb(
final yacyURL url,
final int socketTimeout,
final boolean keepInMemory,
diff --git a/source/de/anomic/crawler/FTPLoader.java b/source/de/anomic/crawler/FTPLoader.java
index dab1224e1..02ab999ae 100644
--- a/source/de/anomic/crawler/FTPLoader.java
+++ b/source/de/anomic/crawler/FTPLoader.java
@@ -34,12 +34,15 @@ import java.io.PrintStream;
import java.io.PrintWriter;
import java.util.Date;
+import de.anomic.http.JakartaCommonsHttpClient;
+import de.anomic.http.httpRequestHeader;
+import de.anomic.http.httpResponseHeader;
import de.anomic.http.httpdProxyCacheEntry;
+import de.anomic.index.indexDocumentMetadata;
import de.anomic.net.ftpc;
import de.anomic.plasma.plasmaHTCache;
import de.anomic.plasma.plasmaParser;
import de.anomic.plasma.plasmaSwitchboard;
-import de.anomic.plasma.cache.ftp.ResourceInfo;
import de.anomic.server.logging.serverLog;
import de.anomic.yacy.yacyURL;
@@ -55,11 +58,17 @@ public class FTPLoader {
maxFileSize = (int) sb.getConfigLong("crawler.ftp.maxFileSize", -1l);
}
- protected httpdProxyCacheEntry createCacheEntry(final CrawlEntry entry, final String mimeType,
- final Date fileDate) {
- return plasmaHTCache.newEntry(entry.depth(), entry.url(), entry.name(), "OK", new ResourceInfo(
- entry.url(), sb.getURL(entry.referrerhash()), mimeType, fileDate), entry.initiator(),
- sb.webIndex.profilesActiveCrawls.getEntry(entry.profileHandle()));
+ protected indexDocumentMetadata createCacheEntry(final CrawlEntry entry, final String mimeType, final Date fileDate) {
+ httpRequestHeader requestHeader = new httpRequestHeader();
+ requestHeader.put(httpRequestHeader.REFERER, sb.getURL(entry.referrerhash()).toNormalform(true, false));
+ httpResponseHeader responseHeader = new httpResponseHeader();
+ responseHeader.put(httpResponseHeader.LAST_MODIFIED, JakartaCommonsHttpClient.date2String(fileDate));
+ responseHeader.put(httpResponseHeader.CONTENT_TYPE, mimeType);
+ indexDocumentMetadata metadata = new httpdProxyCacheEntry(entry.depth(), entry.url(), entry.name(), "OK",
+ requestHeader, responseHeader,
+ entry.initiator(), sb.webIndex.profilesActiveCrawls.getEntry(entry.profileHandle()));
+ plasmaHTCache.storeMetadata(responseHeader, metadata);
+ return metadata;
}
/**
@@ -68,13 +77,13 @@ public class FTPLoader {
* @param entry
* @return
*/
- public httpdProxyCacheEntry load(final CrawlEntry entry) {
+ public indexDocumentMetadata load(final CrawlEntry entry) {
final yacyURL entryUrl = entry.url();
final String fullPath = getPath(entryUrl);
final File cacheFile = createCachefile(entryUrl);
// the return value
- httpdProxyCacheEntry htCache = null;
+ indexDocumentMetadata htCache = null;
// determine filename and path
String file, path;
@@ -163,7 +172,7 @@ public class FTPLoader {
// testing if the file already exists
if (cacheFile.isFile()) {
// delete the file if it already exists
- plasmaHTCache.deleteURLfromCache(entryUrl);
+ plasmaHTCache.deleteURLfromCache(entryUrl, false);
} else {
// create parent directories
cacheFile.getParentFile().mkdirs();
@@ -233,7 +242,7 @@ public class FTPLoader {
* @return
* @throws Exception
*/
- private httpdProxyCacheEntry getFile(final ftpc ftpClient, final CrawlEntry entry, final File cacheFile)
+ private indexDocumentMetadata getFile(final ftpc ftpClient, final CrawlEntry entry, final File cacheFile)
throws Exception {
// determine the mimetype of the resource
final yacyURL entryUrl = entry.url();
@@ -243,7 +252,7 @@ public class FTPLoader {
// if the mimetype and file extension is supported we start to download
// the file
- httpdProxyCacheEntry htCache = null;
+ indexDocumentMetadata htCache = null;
if (plasmaParser.supportedContent(plasmaParser.PARSER_MODE_CRAWLER, entryUrl, mimeType)) {
// aborting download if content is too long
final int size = ftpClient.fileSize(path);
diff --git a/source/de/anomic/crawler/HTTPLoader.java b/source/de/anomic/crawler/HTTPLoader.java
index 0e9e054bd..b0aa2ca76 100644
--- a/source/de/anomic/crawler/HTTPLoader.java
+++ b/source/de/anomic/crawler/HTTPLoader.java
@@ -38,18 +38,18 @@ import java.util.Date;
import de.anomic.http.HttpClient;
import de.anomic.http.JakartaCommonsHttpClient;
import de.anomic.http.JakartaCommonsHttpResponse;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
+import de.anomic.http.httpResponseHeader;
import de.anomic.http.httpdBoundedSizeOutputStream;
import de.anomic.http.httpdByteCountOutputStream;
import de.anomic.http.httpdLimitExceededException;
import de.anomic.http.httpdProxyCacheEntry;
+import de.anomic.index.indexDocumentMetadata;
import de.anomic.index.indexReferenceBlacklist;
import de.anomic.plasma.plasmaHTCache;
import de.anomic.plasma.plasmaParser;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.plasma.plasmaSwitchboardConstants;
-import de.anomic.plasma.cache.IResourceInfo;
-import de.anomic.plasma.cache.http.ResourceInfo;
import de.anomic.server.serverSystem;
import de.anomic.server.logging.serverLog;
import de.anomic.yacy.yacyURL;
@@ -96,24 +96,26 @@ public final class HTTPLoader {
* @param responseStatus Status-Code SPACE Reason-Phrase
* @return
*/
- protected httpdProxyCacheEntry createCacheEntry(final CrawlEntry entry, final Date requestDate, final httpHeader requestHeader, final httpHeader responseHeader, final String responseStatus) {
- final IResourceInfo resourceInfo = new ResourceInfo(entry.url(), requestHeader, responseHeader);
- return plasmaHTCache.newEntry(
+ protected indexDocumentMetadata createCacheEntry(final CrawlEntry entry, final Date requestDate, final httpRequestHeader requestHeader, final httpResponseHeader responseHeader, final String responseStatus) {
+ indexDocumentMetadata metadata = new httpdProxyCacheEntry(
entry.depth(),
entry.url(),
entry.name(),
responseStatus,
- resourceInfo,
+ requestHeader,
+ responseHeader,
entry.initiator(),
sb.webIndex.profilesActiveCrawls.getEntry(entry.profileHandle())
);
+ plasmaHTCache.storeMetadata(responseHeader, metadata);
+ return metadata;
}
- public httpdProxyCacheEntry load(final CrawlEntry entry, final String parserMode) {
+ public indexDocumentMetadata load(final CrawlEntry entry, final String parserMode) {
return load(entry, parserMode, DEFAULT_CRAWLING_RETRY_COUNT);
}
- private httpdProxyCacheEntry load(final CrawlEntry entry, final String parserMode, final int retryCount) {
+ private indexDocumentMetadata load(final CrawlEntry entry, final String parserMode, final int retryCount) {
if (retryCount < 0) {
this.log.logInfo("Redirection counter exceeded for URL " + entry.url().toString() + ". Processing aborted.");
@@ -137,18 +139,18 @@ public final class HTTPLoader {
}
// take a file from the net
- httpdProxyCacheEntry htCache = null;
+ indexDocumentMetadata htCache = null;
final long maxFileSize = sb.getConfigLong("crawler.http.maxFileSize", DEFAULT_MAXFILESIZE);
try {
// create a request header
- final httpHeader requestHeader = new httpHeader();
- requestHeader.put(httpHeader.USER_AGENT, crawlerUserAgent);
+ final httpRequestHeader requestHeader = new httpRequestHeader();
+ requestHeader.put(httpRequestHeader.USER_AGENT, crawlerUserAgent);
yacyURL refererURL = null;
if (entry.referrerhash() != null) refererURL = sb.getURL(entry.referrerhash());
- if (refererURL != null) requestHeader.put(httpHeader.REFERER, refererURL.toNormalform(true, true));
- requestHeader.put(httpHeader.ACCEPT_LANGUAGE, sb.getConfig("crawler.http.acceptLanguage", DEFAULT_LANGUAGE));
- requestHeader.put(httpHeader.ACCEPT_CHARSET, sb.getConfig("crawler.http.acceptCharset", DEFAULT_CHARSET));
- requestHeader.put(httpHeader.ACCEPT_ENCODING, sb.getConfig("crawler.http.acceptEncoding", DEFAULT_ENCODING));
+ if (refererURL != null) requestHeader.put(httpRequestHeader.REFERER, refererURL.toNormalform(true, true));
+ requestHeader.put(httpRequestHeader.ACCEPT_LANGUAGE, sb.getConfig("crawler.http.acceptLanguage", DEFAULT_LANGUAGE));
+ requestHeader.put(httpRequestHeader.ACCEPT_CHARSET, sb.getConfig("crawler.http.acceptCharset", DEFAULT_CHARSET));
+ requestHeader.put(httpRequestHeader.ACCEPT_ENCODING, sb.getConfig("crawler.http.acceptEncoding", DEFAULT_ENCODING));
// HTTP-Client
final JakartaCommonsHttpClient client = new JakartaCommonsHttpClient(socketTimeout, requestHeader);
@@ -200,7 +202,7 @@ public final class HTTPLoader {
fos = new FileOutputStream(cacheFile);
// getting content length
- final long contentLength = res.getResponseHeader().contentLength();
+ final long contentLength = res.getResponseHeader().getContentLength();
// check the maximum allowed file size
if (contentLength == -1 || maxFileSize == -1) {
@@ -247,9 +249,9 @@ public final class HTTPLoader {
htCache = null;
}
} else if (res.getStatusLine().startsWith("30")) {
- if (res.getResponseHeader().containsKey(httpHeader.LOCATION)) {
+ if (res.getResponseHeader().containsKey(httpRequestHeader.LOCATION)) {
// getting redirection URL
- String redirectionUrlString = res.getResponseHeader().get(httpHeader.LOCATION);
+ String redirectionUrlString = res.getResponseHeader().get(httpRequestHeader.LOCATION);
redirectionUrlString = redirectionUrlString.trim();
if (redirectionUrlString.length() == 0) {
diff --git a/source/de/anomic/crawler/IndexingStack.java b/source/de/anomic/crawler/IndexingStack.java
index 2460f7d1e..bf8b93b59 100644
--- a/source/de/anomic/crawler/IndexingStack.java
+++ b/source/de/anomic/crawler/IndexingStack.java
@@ -34,6 +34,7 @@ import java.util.Date;
import java.util.Iterator;
import java.util.concurrent.ConcurrentHashMap;
+import de.anomic.http.httpResponseHeader;
import de.anomic.index.indexURLReference;
import de.anomic.kelondro.kelondroBase64Order;
import de.anomic.kelondro.kelondroNaturalOrder;
@@ -42,7 +43,7 @@ import de.anomic.kelondro.kelondroStack;
import de.anomic.plasma.plasmaHTCache;
import de.anomic.plasma.plasmaSwitchboardConstants;
import de.anomic.plasma.plasmaWordIndex;
-import de.anomic.plasma.cache.IResourceInfo;
+import de.anomic.server.serverDate;
import de.anomic.server.logging.serverLog;
import de.anomic.yacy.yacySeed;
import de.anomic.yacy.yacySeedDB;
@@ -219,7 +220,7 @@ public class IndexingStack {
// computed values
private CrawlProfile.entry profileEntry;
- private IResourceInfo contentInfo;
+ private httpResponseHeader responseHeader;
private yacyURL referrerURL;
public QueueEntry(final yacyURL url, final String referrer, final Date ifModifiedSince, final boolean requestWithCookie,
@@ -234,7 +235,7 @@ public class IndexingStack {
this.anchorName = (anchorName==null)?"":anchorName.trim();
this.profileEntry = null;
- this.contentInfo = null;
+ this.responseHeader = null;
this.referrerURL = null;
this.status = QUEUE_STATE_FRESH;
}
@@ -256,7 +257,7 @@ public class IndexingStack {
this.anchorName = row.getColString(7, "UTF-8");
this.profileEntry = null;
- this.contentInfo = null;
+ this.responseHeader = null;
this.referrerURL = null;
this.status = QUEUE_STATE_FRESH;
}
@@ -278,7 +279,7 @@ public class IndexingStack {
this.anchorName = (row[7] == null) ? null : (new String(row[7], "UTF-8")).trim();
this.profileEntry = null;
- this.contentInfo = null;
+ this.responseHeader = null;
this.referrerURL = null;
this.status = QUEUE_STATE_FRESH;
}
@@ -344,29 +345,27 @@ public class IndexingStack {
return profileEntry;
}
- private IResourceInfo getCachedObjectInfo() {
- if (this.contentInfo == null) try {
- this.contentInfo = plasmaHTCache.loadResourceInfo(this.url);
+ private void getResponseHeader() {
+ if (this.responseHeader == null) try {
+ this.responseHeader = plasmaHTCache.loadResponseHeader(this.url);
} catch (final Exception e) {
serverLog.logSevere("PLASMA", "responseHeader: failed to get header", e);
- return null;
}
- return this.contentInfo;
}
public String getMimeType() {
- final IResourceInfo info = this.getCachedObjectInfo();
- return (info == null) ? null : info.getMimeType();
+ this.getResponseHeader();
+ return (responseHeader == null) ? null : responseHeader.mime();
}
public String getCharacterEncoding() {
- final IResourceInfo info = this.getCachedObjectInfo();
- return (info == null) ? null : info.getCharacterEncoding();
+ getResponseHeader();
+ return (responseHeader == null) ? null : responseHeader.getCharacterEncoding();
}
public Date getModificationDate() {
- final IResourceInfo info = this.getCachedObjectInfo();
- return (info == null) ? new Date() : info.getModificationDate();
+ getResponseHeader();
+ return (responseHeader == null) ? new Date() : responseHeader.lastModified();
}
public yacyURL referrerURL() {
@@ -458,8 +457,95 @@ public class IndexingStack {
return "Dynamic_(Requested_With_Cookie)";
}
- if (getCachedObjectInfo() != null) {
- return this.getCachedObjectInfo().shallIndexCacheForProxy();
+ getResponseHeader();
+ if (responseHeader != null) {
+ // -set-cookie in response
+ // the set-cookie from the server does not indicate that the content is special
+ // thus we do not care about it here for indexing
+
+ // a picture cannot be indexed
+ final String mimeType = responseHeader.mime();
+ if (plasmaHTCache.isPicture(mimeType)) {
+ return "Media_Content_(Picture)";
+ }
+ if (!plasmaHTCache.isText(mimeType)) {
+ return "Media_Content_(not_text)";
+ }
+
+ // -if-modified-since in request
+ // if the page is fresh at the very moment we can index it
+ final Date ifModifiedSince = getModificationDate();
+ if ((ifModifiedSince != null) && (responseHeader.containsKey(httpResponseHeader.LAST_MODIFIED))) {
+ // parse date
+ Date d = responseHeader.lastModified();
+ if (d == null) {
+ d = new Date(serverDate.correctedUTCTime());
+ }
+ // finally, we shall treat the cache as stale if the modification time is after the if-.. time
+ if (d.after(ifModifiedSince)) {
+ //System.out.println("***not indexed because if-modified-since");
+ return "Stale_(Last-Modified>Modified-Since)";
+ }
+ }
+
+ // -pragma in cached response
+ if (responseHeader.containsKey(httpResponseHeader.PRAGMA) &&
+ (responseHeader.get(httpResponseHeader.PRAGMA)).toUpperCase().equals("NO-CACHE")) {
+ return "Denied_(pragma_no_cache)";
+ }
+
+ // see for documentation also:
+ // http://www.web-caching.com/cacheability.html
+
+ // look for freshnes information
+
+ // -expires in cached response
+ // the expires value gives us a very easy hint when the cache is stale
+ // sometimes, the expires date is set to the past to prevent that a page is cached
+ // we use that information to see if we should index it
+ final Date expires = responseHeader.expires();
+ if (expires != null && expires.before(new Date(serverDate.correctedUTCTime()))) {
+ return "Stale_(Expired)";
+ }
+
+ // -lastModified in cached response
+ // this information is too weak to use it to prevent indexing
+ // even if we can apply a TTL heuristic for cache usage
+
+ // -cache-control in cached response
+ // the cache-control has many value options.
+ String cacheControl = responseHeader.get(httpResponseHeader.CACHE_CONTROL);
+ if (cacheControl != null) {
+ cacheControl = cacheControl.trim().toUpperCase();
+ /* we have the following cases for cache-control:
+ "public" -- can be indexed
+ "private", "no-cache", "no-store" -- cannot be indexed
+ "max-age=<delta-seconds>" -- stale/fresh dependent on date
+ */
+ if (cacheControl.startsWith("PRIVATE") ||
+ cacheControl.startsWith("NO-CACHE") ||
+ cacheControl.startsWith("NO-STORE")) {
+ // easy case
+ return "Stale_(denied_by_cache-control=" + cacheControl + ")";
+ // } else if (cacheControl.startsWith("PUBLIC")) {
+ // // ok, do nothing
+ } else if (cacheControl.startsWith("MAX-AGE=")) {
+ // we need also the load date
+ final Date date = responseHeader.date();
+ if (date == null) {
+ return "Stale_(no_date_given_in_response)";
+ }
+ try {
+ final long ttl = 1000 * Long.parseLong(cacheControl.substring(8)); // milliseconds to live
+ if (serverDate.correctedUTCTime() - date.getTime() > ttl) {
+ //System.out.println("***not indexed because cache-control");
+ return "Stale_(expired_by_cache-control)";
+ }
+ } catch (final Exception e) {
+ return "Error_(" + e.getMessage() + ")";
+ }
+ }
+ }
}
return null;
}
@@ -496,9 +582,11 @@ public class IndexingStack {
// we checked that in shallStoreCache
// a picture cannot be indexed
- if (getCachedObjectInfo() != null) {
- final String status = this.getCachedObjectInfo().shallIndexCacheForCrawler();
- if (status != null) return status;
+ getResponseHeader();
+ if (responseHeader != null) {
+ final String mimeType = responseHeader.mime();
+ if (plasmaHTCache.isPicture(mimeType)) { return "Media_Content_(Picture)"; }
+ if (!plasmaHTCache.isText(mimeType)) { return "Media_Content_(not_text)"; }
}
if (plasmaHTCache.noIndexingURL(url())) { return "Media_Content_(forbidden)"; }
diff --git a/source/de/anomic/crawler/LoaderMessage.java b/source/de/anomic/crawler/LoaderMessage.java
index c9c5e287a..7d0ef24d7 100644
--- a/source/de/anomic/crawler/LoaderMessage.java
+++ b/source/de/anomic/crawler/LoaderMessage.java
@@ -23,7 +23,7 @@
package de.anomic.crawler;
-import de.anomic.http.httpdProxyCacheEntry;
+import de.anomic.index.indexDocumentMetadata;
import de.anomic.server.serverSemaphore;
import de.anomic.yacy.yacyURL;
@@ -41,7 +41,7 @@ public final class LoaderMessage {
public final boolean keepInMemory;
private serverSemaphore resultSync = null;
- private httpdProxyCacheEntry result;
+ private indexDocumentMetadata result;
private String errorMessage;
// loadParallel(URL url, String referer, String initiator, int depth, plasmaCrawlProfile.entry profile) {
@@ -80,7 +80,7 @@ public final class LoaderMessage {
return this.errorMessage;
}
- public void setResult(final httpdProxyCacheEntry theResult) {
+ public void setResult(final indexDocumentMetadata theResult) {
// store the result
this.result = theResult;
@@ -88,8 +88,8 @@ public final class LoaderMessage {
this.resultSync.V();
}
- public httpdProxyCacheEntry waitForResult() throws InterruptedException {
- httpdProxyCacheEntry theResult = null;
+ public indexDocumentMetadata waitForResult() throws InterruptedException {
+ indexDocumentMetadata theResult = null;
this.resultSync.P();
/* =====> CRITICAL SECTION <======== */
diff --git a/source/de/anomic/crawler/ProtocolLoader.java b/source/de/anomic/crawler/ProtocolLoader.java
index 0044a12ad..88fb464b5 100644
--- a/source/de/anomic/crawler/ProtocolLoader.java
+++ b/source/de/anomic/crawler/ProtocolLoader.java
@@ -32,7 +32,7 @@ import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-import de.anomic.http.httpdProxyCacheEntry;
+import de.anomic.index.indexDocumentMetadata;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverCore;
import de.anomic.server.logging.serverLog;
@@ -68,7 +68,7 @@ public final class ProtocolLoader {
return (HashSet<String>) this.supportedProtocols.clone();
}
- public httpdProxyCacheEntry load(final CrawlEntry entry, final String parserMode) {
+ public indexDocumentMetadata load(final CrawlEntry entry, final String parserMode) {
// getting the protocol of the next URL
final String protocol = entry.url().getProtocol();
final String host = entry.url().getHost();
@@ -109,7 +109,7 @@ public final class ProtocolLoader {
public String process(final CrawlEntry entry, final String parserMode) {
// load a resource, store it to htcache and push queue entry to switchboard queue
// returns null if everything went fine, a fail reason string if a problem occurred
- httpdProxyCacheEntry h;
+ indexDocumentMetadata h;
try {
h = load(entry, parserMode);
entry.setStatus("loaded");
diff --git a/source/de/anomic/crawler/RobotsTxt.java b/source/de/anomic/crawler/RobotsTxt.java
index 1e6c45d7f..7f9fad4b8 100644
--- a/source/de/anomic/crawler/RobotsTxt.java
+++ b/source/de/anomic/crawler/RobotsTxt.java
@@ -42,7 +42,7 @@ import java.util.concurrent.ConcurrentHashMap;
import de.anomic.http.HttpClient;
import de.anomic.http.JakartaCommonsHttpClient;
import de.anomic.http.JakartaCommonsHttpResponse;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.kelondro.kelondroBLOB;
import de.anomic.kelondro.kelondroBLOBHeap;
import de.anomic.kelondro.kelondroBLOBTree;
@@ -496,19 +496,19 @@ public class RobotsTxt {
downloadStart = System.currentTimeMillis();
// if we previously have downloaded this robots.txt then we can set the if-modified-since header
- httpHeader reqHeaders = new httpHeader();
+ httpRequestHeader reqHeaders = new httpRequestHeader();
// add yacybot user agent
- reqHeaders.put(httpHeader.USER_AGENT, HTTPLoader.crawlerUserAgent);
+ reqHeaders.put(httpRequestHeader.USER_AGENT, HTTPLoader.crawlerUserAgent);
// adding referer
- reqHeaders.put(httpHeader.REFERER, (yacyURL.newURL(robotsURL,"/")).toNormalform(true, true));
+ reqHeaders.put(httpRequestHeader.REFERER, (yacyURL.newURL(robotsURL,"/")).toNormalform(true, true));
if (entry != null) {
oldEtag = entry.getETag();
- reqHeaders = new httpHeader();
+ reqHeaders = new httpRequestHeader();
final Date modDate = entry.getModDate();
- if (modDate != null) reqHeaders.put(httpHeader.IF_MODIFIED_SINCE,HttpClient.dateString(entry.getModDate()));
+ if (modDate != null) reqHeaders.put(httpRequestHeader.IF_MODIFIED_SINCE,HttpClient.dateString(entry.getModDate()));
}
@@ -531,7 +531,7 @@ public class RobotsTxt {
} else {
// getting some metadata
- eTag = res.getResponseHeader().containsKey(httpHeader.ETAG)?(res.getResponseHeader().get(httpHeader.ETAG)).trim():null;
+ eTag = res.getResponseHeader().containsKey(httpRequestHeader.ETAG)?(res.getResponseHeader().get(httpRequestHeader.ETAG)).trim():null;
lastMod = res.getResponseHeader().lastModified();
// if the robots.txt file was not changed we break here
@@ -556,7 +556,7 @@ public class RobotsTxt {
return null;
} else if (res.getStatusLine().startsWith("3")) {
// getting redirection URL
- String redirectionUrlString = res.getResponseHeader().get(httpHeader.LOCATION);
+ String redirectionUrlString = res.getResponseHeader().get(httpRequestHeader.LOCATION);
if (redirectionUrlString==null) {
serverLog.logFinest("ROBOTS","robots.txt could not be downloaded from URL '" + robotsURL + "' because of missing redirecton header. [" + res.getStatusLine() + "].");
robotsTxt = null;
diff --git a/source/de/anomic/data/SitemapParser.java b/source/de/anomic/data/SitemapParser.java
index a25202c5c..f4556e559 100644
--- a/source/de/anomic/data/SitemapParser.java
+++ b/source/de/anomic/data/SitemapParser.java
@@ -44,7 +44,7 @@ import de.anomic.crawler.HTTPLoader;
import de.anomic.crawler.ZURL;
import de.anomic.http.JakartaCommonsHttpClient;
import de.anomic.http.JakartaCommonsHttpResponse;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.http.httpdByteCountInputStream;
import de.anomic.index.indexURLReference;
import de.anomic.plasma.plasmaSwitchboard;
@@ -152,9 +152,9 @@ public class SitemapParser extends DefaultHandler {
*/
public void parse() {
// download document
- final httpHeader header = new httpHeader();
- header.put(httpHeader.USER_AGENT, HTTPLoader.crawlerUserAgent);
- final JakartaCommonsHttpClient client = new JakartaCommonsHttpClient(5000, header);
+ final httpRequestHeader requestHeader = new httpRequestHeader();
+ requestHeader.put(httpRequestHeader.USER_AGENT, HTTPLoader.crawlerUserAgent);
+ final JakartaCommonsHttpClient client = new JakartaCommonsHttpClient(5000, requestHeader);
JakartaCommonsHttpResponse res = null;
try {
res = client.GET(siteMapURL.toString());
@@ -166,7 +166,7 @@ public class SitemapParser extends DefaultHandler {
// getting some metadata
final String contentMimeType = res.getResponseHeader().mime();
- this.contentLength = res.getResponseHeader().contentLength();
+ this.contentLength = res.getResponseHeader().getContentLength();
try {
InputStream contentStream = res.getDataAsStream();
diff --git a/source/de/anomic/data/userDB.java b/source/de/anomic/data/userDB.java
index 6cc3a38e7..afb9f1b0e 100644
--- a/source/de/anomic/data/userDB.java
+++ b/source/de/anomic/data/userDB.java
@@ -35,7 +35,7 @@ import java.util.Iterator;
import java.util.Map;
import java.util.Random;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.kelondro.kelondroBLOBTree;
import de.anomic.kelondro.kelondroBase64Order;
import de.anomic.kelondro.kelondroCloneableIterator;
@@ -138,8 +138,8 @@ public final class userDB {
}
return null;
}
- public Entry getUser(final httpHeader header){
- return getUser(header.get(httpHeader.AUTHORIZATION), header.get(httpHeader.CONNECTION_PROP_CLIENTIP), header.getHeaderCookies());
+ public Entry getUser(final httpRequestHeader header){
+ return getUser(header.get(httpRequestHeader.AUTHORIZATION), header.get(httpRequestHeader.CONNECTION_PROP_CLIENTIP), header.getHeaderCookies());
}
public Entry getUser(final String auth, final String ip, final String cookies){
Entry entry=null;
diff --git a/source/de/anomic/htmlFilter/htmlFilterContentScraper.java b/source/de/anomic/htmlFilter/htmlFilterContentScraper.java
index 1c2b14a91..4feab2a3a 100644
--- a/source/de/anomic/htmlFilter/htmlFilterContentScraper.java
+++ b/source/de/anomic/htmlFilter/htmlFilterContentScraper.java
@@ -46,7 +46,7 @@ import javax.swing.event.EventListenerList;
import de.anomic.crawler.HTTPLoader;
import de.anomic.data.htmlTools;
import de.anomic.http.HttpClient;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.server.serverCharBuffer;
import de.anomic.server.serverFileUtils;
import de.anomic.yacy.yacyURL;
@@ -493,8 +493,8 @@ public class htmlFilterContentScraper extends htmlFilterAbstractScraper implemen
public static htmlFilterContentScraper parseResource(final yacyURL location) throws IOException {
// load page
- final httpHeader reqHeader = new httpHeader();
- reqHeader.put(httpHeader.USER_AGENT, HTTPLoader.crawlerUserAgent);
+ final httpRequestHeader reqHeader = new httpRequestHeader();
+ reqHeader.put(httpRequestHeader.USER_AGENT, HTTPLoader.crawlerUserAgent);
final byte[] page = HttpClient.wget(location.toString(), reqHeader, 10000);
if (page == null) throw new IOException("no response from url " + location.toString());
diff --git a/source/de/anomic/htmlFilter/htmlFilterInputStream.java b/source/de/anomic/htmlFilter/htmlFilterInputStream.java
index 41109bf51..24c9db808 100644
--- a/source/de/anomic/htmlFilter/htmlFilterInputStream.java
+++ b/source/de/anomic/htmlFilter/htmlFilterInputStream.java
@@ -35,7 +35,6 @@ import java.io.UnsupportedEncodingException;
import java.io.Writer;
import java.util.Properties;
-import de.anomic.http.httpHeader;
import de.anomic.yacy.yacyURL;
public class htmlFilterInputStream extends InputStream implements htmlFilterEventListener {
@@ -73,6 +72,25 @@ public class htmlFilterInputStream extends InputStream implements htmlFilterEven
this.writer = new htmlFilterWriter(null,null,scraper,transformer,passbyIfBinarySuspect);
}
+ private static String extractCharsetFromMimetypeHeader(final String mimeType) {
+ if (mimeType == null) return null;
+
+ final String[] parts = mimeType.split(";");
+ if (parts == null || parts.length <= 1) return null;
+
+ for (int i=1; i < parts.length; i++) {
+ final String param = parts[i].trim();
+ if (param.startsWith("charset=")) {
+ String charset = param.substring("charset=".length()).trim();
+ if (charset.startsWith("\"") || charset.startsWith("'")) charset = charset.substring(1);
+ if (charset.endsWith("\"") || charset.endsWith("'")) charset = charset.substring(0,charset.length()-1);
+ return charset.trim();
+ }
+ }
+
+ return null;
+ }
+
public void scrapeTag0(final String tagname, final Properties tagopts) {
if (tagname == null || tagname.length() == 0) return;
@@ -80,8 +98,9 @@ public class htmlFilterInputStream extends InputStream implements htmlFilterEven
if (tagopts.containsKey("http-equiv")) {
final String value = tagopts.getProperty("http-equiv");
if (value.equalsIgnoreCase("Content-Type")) {
+ // parse lines like <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
final String contentType = tagopts.getProperty("content","");
- this.detectedCharset = httpHeader.extractCharsetFromMimetypeHeader(contentType);
+ this.detectedCharset = extractCharsetFromMimetypeHeader(contentType);
if (this.detectedCharset != null && this.detectedCharset.length() > 0) {
this.charsetChanged = true;
} else if (tagopts.containsKey("charset")) {
diff --git a/source/de/anomic/http/HttpClient.java b/source/de/anomic/http/HttpClient.java
index e1b3de354..c55580179 100644
--- a/source/de/anomic/http/HttpClient.java
+++ b/source/de/anomic/http/HttpClient.java
@@ -88,10 +88,10 @@ public abstract class HttpClient {
* @param timeout in milliseconds
* @return
*/
- public static byte[] wget(final String uri, final httpHeader header, final int timeout) {
+ public static byte[] wget(final String uri, final httpRequestHeader header, final int timeout) {
return wget(uri, header, timeout, null);
}
- public static byte[] wget(final String uri, final httpHeader header, final int timeout, final String vhost) {
+ public static byte[] wget(final String uri, final httpRequestHeader header, final int timeout, final String vhost) {
assert uri != null : "precondition violated: uri != null";
addHostHeader(header, vhost);
final JakartaCommonsHttpClient client = new JakartaCommonsHttpClient(timeout, header);
@@ -113,13 +113,13 @@ public abstract class HttpClient {
* @param vhost
* @return
*/
- private static void addHostHeader(httpHeader header, final String vhost) {
+ private static void addHostHeader(httpRequestHeader header, final String vhost) {
if (vhost != null) {
if (header != null) {
- header = new httpHeader();
+ header = new httpRequestHeader();
}
// set host-header
- header.add(httpHeader.HOST, vhost);
+ header.add(httpRequestHeader.HOST, vhost);
}
}
@@ -129,7 +129,7 @@ public abstract class HttpClient {
* @param uri
* @return
*/
- public static httpHeader whead(final String uri) {
+ public static httpResponseHeader whead(final String uri) {
return whead(uri, null);
}
@@ -140,7 +140,7 @@ public abstract class HttpClient {
* @param header request header
* @return null on error
*/
- public static httpHeader whead(final String uri, final httpHeader header) {
+ public static httpResponseHeader whead(final String uri, final httpRequestHeader header) {
final JakartaCommonsHttpClient client = new JakartaCommonsHttpClient(10000, header);
JakartaCommonsHttpResponse response = null;
try {
diff --git a/source/de/anomic/http/JakartaCommonsHttpClient.java b/source/de/anomic/http/JakartaCommonsHttpClient.java
index a9b227695..8d39827a3 100644
--- a/source/de/anomic/http/JakartaCommonsHttpClient.java
+++ b/source/de/anomic/http/JakartaCommonsHttpClient.java
@@ -160,7 +160,7 @@ public class JakartaCommonsHttpClient {
* @param timeout in milliseconds
* @param header header options to send
*/
- public JakartaCommonsHttpClient(final int timeout, final httpHeader header) {
+ public JakartaCommonsHttpClient(final int timeout, final httpRequestHeader header) {
super();
setTimeout(timeout);
setHeader(header);
@@ -175,7 +175,7 @@ public class JakartaCommonsHttpClient {
* @param header header options to send
* @param proxyConfig
*/
- public JakartaCommonsHttpClient(final int timeout, final httpHeader header, final httpRemoteProxyConfig proxyConfig) {
+ public JakartaCommonsHttpClient(final int timeout, final httpRequestHeader header, final httpRemoteProxyConfig proxyConfig) {
super();
setTimeout(timeout);
setHeader(header);
@@ -195,7 +195,7 @@ public class JakartaCommonsHttpClient {
* (non-Javadoc)
* @see de.anomic.http.HttpClient#setHeader(de.anomic.http.httpHeader)
*/
- public void setHeader(final httpHeader header) {
+ public void setHeader(final httpRequestHeader header) {
headers = convertHeaders(header);
}
@@ -322,7 +322,7 @@ public class JakartaCommonsHttpClient {
if (gzipBody) {
data = zipRequest(data);
- post.setRequestHeader(httpHeader.CONTENT_ENCODING, httpHeader.CONTENT_ENCODING_GZIP);
+ post.setRequestHeader(httpResponseHeader.CONTENT_ENCODING, httpHeader.CONTENT_ENCODING_GZIP);
}
post.setRequestEntity(data);
// redirects in POST cause a "Entity enclosing requests cannot be redirected without user intervention" -
@@ -369,7 +369,7 @@ public class JakartaCommonsHttpClient {
* @param requestHeader
* @param method
*/
- public void addHeader(final httpHeader requestHeader, final HttpMethod method) {
+ public void addHeader(final httpRequestHeader requestHeader, final HttpMethod method) {
assert method != null : "precondition violated: method != null";
if (requestHeader != null) {
addHeaders(convertHeaders(requestHeader), method);
@@ -399,7 +399,7 @@ public class JakartaCommonsHttpClient {
* @param requestHeader
* @return
*/
- private static Header[] convertHeaders(final httpHeader requestHeader) {
+ private static Header[] convertHeaders(final httpRequestHeader requestHeader) {
final Header[] headers;
if (requestHeader == null) {
headers = new Header[0];
@@ -537,7 +537,7 @@ public class JakartaCommonsHttpClient {
final String credentials = kelondroBase64Order.standardCoder.encodeString(remoteProxyUser.replace(":",
"") +
":" + remoteProxyPwd);
- method.setRequestHeader(httpHeader.PROXY_AUTHORIZATION, "Basic " + credentials);
+ method.setRequestHeader(httpRequestHeader.PROXY_AUTHORIZATION, "Basic " + credentials);
}
}
}
@@ -587,7 +587,7 @@ public class JakartaCommonsHttpClient {
* @param date The Date-Object to be converted.
* @return String with the date.
*/
- public static String date2String(final Date date) {
+ public static String date2String(final Date date) { // TODO: merge this method with serverDate
if (date == null) {
return "";
}
diff --git a/source/de/anomic/http/JakartaCommonsHttpResponse.java b/source/de/anomic/http/JakartaCommonsHttpResponse.java
index 0644f8690..575e18daf 100644
--- a/source/de/anomic/http/JakartaCommonsHttpResponse.java
+++ b/source/de/anomic/http/JakartaCommonsHttpResponse.java
@@ -67,8 +67,8 @@ public class JakartaCommonsHttpResponse {
*
* @see de.anomic.http.HttpResponse#getResponseHeader()
*/
- public httpHeader getResponseHeader() {
- final httpHeader responseHeader = new httpHeader();
+ public httpResponseHeader getResponseHeader() {
+ final httpResponseHeader responseHeader = new httpResponseHeader();
for (final Header header : getHeaders()) {
responseHeader.add(header.getName(), header.getValue());
}
diff --git a/source/de/anomic/http/httpChunkedInputStream.java b/source/de/anomic/http/httpChunkedInputStream.java
index 0e2cab776..4b134ef9d 100644
--- a/source/de/anomic/http/httpChunkedInputStream.java
+++ b/source/de/anomic/http/httpChunkedInputStream.java
@@ -49,7 +49,7 @@ public final class httpChunkedInputStream extends InputStream {
private final InputStream inputStream;
private int currPos;
private int currChunkSize;
- private httpHeader httpTrailer;
+ private httpRequestHeader httpTrailer;
private boolean beginningOfStream = true;
private boolean isEOF = false;
@@ -108,7 +108,6 @@ public final class httpChunkedInputStream extends InputStream {
}
}
-
private void readNextChunk() throws IOException {
if (!this.beginningOfStream) readCRLF();
@@ -121,7 +120,6 @@ public final class httpChunkedInputStream extends InputStream {
}
}
-
private void readTrailer() throws IOException {
BufferedReader reader = null;
serverByteBuffer bout = null;
@@ -140,19 +138,15 @@ public final class httpChunkedInputStream extends InputStream {
final ByteArrayInputStream bin = new ByteArrayInputStream(bout.getBytes());
reader = new BufferedReader(new InputStreamReader(bin));
- this.httpTrailer = httpHeader.readHttpHeader(reader);
+ this.httpTrailer = new httpRequestHeader();
+ this.httpTrailer.readHttpHeader(reader);
} finally {
if (reader != null) try {reader.close();}catch(final Exception e){}
if (bout != null) try {bout.close();}catch(final Exception e){}
}
}
- public httpHeader getTrailer() {
- return this.httpTrailer;
- }
-
- private static int readChunkFromStream(final InputStream in)
- throws IOException {
+ private static int readChunkFromStream(final InputStream in) throws IOException {
final serverByteBuffer baos = new serverByteBuffer();
int state = READ_CHUNK_STATE_NORMAL;
diff --git a/source/de/anomic/http/httpHeader.java b/source/de/anomic/http/httpHeader.java
index 47b2ee9b0..f7f0c67f8 100644
--- a/source/de/anomic/http/httpHeader.java
+++ b/source/de/anomic/http/httpHeader.java
@@ -38,11 +38,8 @@ package de.anomic.http;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
-import java.io.FileReader;
import java.io.IOException;
import java.net.MalformedURLException;
-import java.net.URL;
-import java.nio.charset.Charset;
import java.text.Collator;
import java.util.Date;
import java.util.HashMap;
@@ -53,13 +50,11 @@ import java.util.Properties;
import java.util.TreeMap;
import java.util.Vector;
-import de.anomic.server.serverCore;
import de.anomic.server.serverDate;
-import de.anomic.server.logging.serverLog;
import de.anomic.yacy.yacyURL;
-public final class httpHeader extends TreeMap<String, String> implements Map<String, String> {
+public class httpHeader extends TreeMap<String, String> implements Map<String, String> {
private static final long serialVersionUID = 18L;
@@ -76,69 +71,35 @@ public final class httpHeader extends TreeMap<String, String> implements Map<Str
/* =============================================================
* Constants defining http header names
* ============================================================= */
- public static final String ACCEPT = "Accept";
- public static final String ACCEPT_CHARSET = "Accept-Charset";
- public static final String ACCEPT_LANGUAGE = "Accept-Language";
+ // TODO: sort these header properties into request and response properties (some are both)
public static final String HOST = "Host";
-
- public static final String CONNECTION = "Connection";
- public static final String PROXY_CONNECTION = "Proxy-Connection";
- public static final String KEEP_ALIVE = "Keep-Alive";
-
- public static final String REFERER = "Referer";
public static final String USER_AGENT = "User-Agent";
- public static final String AUTHORIZATION = "Authorization";
- public static final String WWW_AUTHENTICATE = "WWW-Authenticate";
- public static final String PROXY_AUTHORIZATION = "Proxy-Authorization";
- public static final String PROXY_AUTHENTICATE = "Proxy-Authenticate";
-
- public static final String DATE = "Date";
- public static final String SERVER = "Server";
-
public static final String CONTENT_LENGTH = "Content-Length";
public static final String CONTENT_TYPE = "Content-Type";
public static final String CONTENT_MD5 = "Content-MD5";
public static final String CONTENT_LOCATION = "Content-Location";
-
- public static final String SET_COOKIE = "Set-Cookie";
- public static final String SET_COOKIE2 = "Set-Cookie2";
- public static final String COOKIE = "Cookie";
- public static final String EXPIRES = "Expires";
-
-
- public static final String ACCEPT_ENCODING = "Accept-Encoding";
public static final String CONTENT_ENCODING = "Content-Encoding";
public static final String TRANSFER_ENCODING = "Transfer-Encoding";
+ public static final String PRAGMA = "Pragma";
+ public static final String CACHE_CONTROL = "Cache-Control";
+
+ public static final String DATE = "Date";
+ public static final String SERVER = "Server";
public static final String ACCEPT_RANGES = "Accept-Ranges";
public static final String CONTENT_RANGE = "Content-Range";
public static final String RANGE = "Range";
- public static final String IF_RANGE = "If-Range";
- public static final String PRAGMA = "Pragma";
- public static final String CACHE_CONTROL = "Cache-Control";
- public static final String IF_MODIFIED_SINCE = "If-Modified-Since";
- public static final String LAST_MODIFIED = "Last-modified";
-
public static final String LOCATION = "Location";
public static final String ETAG = "ETag";
public static final String VIA = "Via";
- public static final String X_CACHE = "X-Cache";
- public static final String X_CACHE_LOOKUP = "X-Cache-Lookup";
public static final String X_FORWARDED_FOR = "X-Forwarded-For";
-
- public static final String X_YACY_KEEP_ALIVE_REQUEST_COUNT = "X-Keep-Alive-Request-Count";
- public static final String X_YACY_ORIGINAL_REQUEST_LINE = "X-Original-Request-Line";
- public static final String X_YACY_PREVIOUS_REQUEST_LINE = "X-Previous-Request-Line";
-
public static final String X_YACY_INDEX_CONTROL = "X-YACY-Index-Control";
- public static final String UPGRADE = "Upgrade";
- public static final String TE = "TE";
/* =============================================================
* Constants for content-encodings
@@ -258,23 +219,6 @@ public final class httpHeader extends TreeMap<String, String> implements Map<Str
this.reverseMappingCache = reverseMappingCache;
}
- public httpHeader(final HashMap<String, String> reverseMappingCache, final File f) throws IOException {
- // creates also a case insensitive map and loads it initially
- // with some values
- super((Collator) insensitiveCollator.clone());
- this.reverseMappingCache = reverseMappingCache;
-
- // load with data
- final BufferedReader br = new BufferedReader(new FileReader(f));
- String line;
- int pos;
- while ((line = br.readLine()) != null) {
- pos = line.indexOf("=");
- if (pos >= 0) put(line.substring(0, pos), line.substring(pos + 1));
- }
- br.close();
- }
-
public httpHeader(final HashMap<String, String> reverseMappingCache, final Map<String, String> othermap) {
// creates a case insensitive map from another map
super((Collator) insensitiveCollator.clone());
@@ -355,46 +299,30 @@ public final class httpHeader extends TreeMap<String, String> implements Map<Str
public String toString() {
return super.toString();
}
+
+
/*
* example header
- Connection=close
- Content-Encoding=gzip
- Content-Length=7281
- Content-Type=text/html
- Date=Mon, 05 Jan 2004 11:55:10 GMT
- Server=Apache/1.3.26
- */
-
- private Date headerDate(final String kind) {
- if (containsKey(kind)) {
- Date parsedDate = serverDate.parseHTTPDate(get(kind));
- if (parsedDate == null) parsedDate = new Date();
- return parsedDate;
- }
- return null;
- }
-
- public String referer() {
- return (String) get(httpHeader.REFERER, "");
- }
-
- public String refererHost() {
- String refererHost = "";
- final String referer = referer();
- if (referer.length() > 0) try { refererHost = (new URL(referer)).getHost(); } catch (final MalformedURLException e) {}
- return refererHost;
- }
+ Connection=close
+ Content-Encoding=gzip
+ Content-Length=7281
+ Content-Type=text/html
+ Date=Mon, 05 Jan 2004 11:55:10 GMT
+ Server=Apache/1.3.26
+ */
public String mime() {
- return (String) get(httpHeader.CONTENT_TYPE, "application/octet-stream");
+ return (String) get(CONTENT_TYPE, "application/octet-stream");
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.commons.fileupload.RequestContext#getCharacterEncoding()
+ */
public String getCharacterEncoding() {
final String mimeType = mime();
- return extractCharsetFromMimetypeHeader(mimeType);
- }
-
- public static String extractCharsetFromMimetypeHeader(final String mimeType) {
if (mimeType == null) return null;
final String[] parts = mimeType.split(";");
@@ -413,48 +341,15 @@ public final class httpHeader extends TreeMap<String, String> implements Map<Str
return null;
}
- public Date date() {
- return headerDate(httpHeader.DATE);
- }
-
- public Date expires() {
- return headerDate(httpHeader.EXPIRES);
- }
-
- public Date lastModified() {
- return headerDate(httpHeader.LAST_MODIFIED);
- }
-
- public Date ifModifiedSince() {
- return headerDate(httpHeader.IF_MODIFIED_SINCE);
- }
-
- public Object ifRange() {
- if (containsKey(httpHeader.IF_RANGE)) {
- final Date rangeDate = serverDate.parseHTTPDate(get(httpHeader.IF_RANGE));
- if (rangeDate != null)
- return rangeDate;
-
- return get(httpHeader.IF_RANGE);
- }
- return null;
- }
-
- public String userAgent() {
- return (String) get(USER_AGENT, "");
- }
-
- public long age() {
- final Date lm = lastModified();
- final Date sd = date();
- if (lm == null) return Long.MAX_VALUE;
- return ((sd == null) ? new Date() : sd).getTime() - lm.getTime();
- }
-
- public long contentLength() {
- if (containsKey(httpHeader.CONTENT_LENGTH)) {
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.commons.fileupload.RequestContext#getContentLength()
+ */
+ public int getContentLength() {
+ if (containsKey(CONTENT_LENGTH)) {
try {
- return Long.parseLong(get(httpHeader.CONTENT_LENGTH));
+ return (int) Long.parseLong(get(CONTENT_LENGTH));
} catch (final NumberFormatException e) {
return -1;
}
@@ -462,171 +357,25 @@ public final class httpHeader extends TreeMap<String, String> implements Map<Str
return -1;
}
- public boolean acceptGzip() {
- return ((containsKey(httpHeader.ACCEPT_ENCODING)) &&
- ((get(httpHeader.ACCEPT_ENCODING)).toUpperCase().indexOf("GZIP")) != -1);
- }
-
- public boolean gzip() {
- return ((containsKey(httpHeader.CONTENT_ENCODING)) &&
- ((get(httpHeader.CONTENT_ENCODING)).toUpperCase().startsWith("GZIP")));
- }
-
- public static Object[] parseResponseLine(final String respLine) {
-
- if ((respLine == null) || (respLine.length() == 0)) {
- return new Object[]{"HTTP/1.0",Integer.valueOf(500),"status line parse error"};
- }
-
- int p = respLine.indexOf(" ");
- if (p < 0) {
- return new Object[]{"HTTP/1.0",Integer.valueOf(500),"status line parse error"};
- }
-
- String httpVer, status, statusText;
- Integer statusCode;
-
- // the http version reported by the server
- httpVer = respLine.substring(0,p);
-
- // Status of the request, e.g. "200 OK"
- status = respLine.substring(p + 1).trim(); // the status code plus reason-phrase
-
- // splitting the status into statuscode and statustext
- p = status.indexOf(" ");
- try {
- statusCode = Integer.valueOf((p < 0) ? status.trim() : status.substring(0,p).trim());
- statusText = (p < 0) ? "" : status.substring(p+1).trim();
- } catch (final Exception e) {
- statusCode = Integer.valueOf(500);
- statusText = status;
- }
-
- return new Object[]{httpVer,statusCode,statusText};
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.commons.fileupload.RequestContext#getContentType()
+ */
+ //@Override
+ public String getContentType() {
+ return get(CONTENT_TYPE);
}
- public static Properties parseRequestLine(final String s, final Properties prop, final String virtualHost) {
- final int p = s.indexOf(" ");
- if (p >= 0) {
- final String cmd = s.substring(0,p);
- final String args = s.substring(p+1);
- return parseRequestLine(cmd,args, prop,virtualHost);
+ protected Date headerDate(final String kind) {
+ if (containsKey(kind)) {
+ Date parsedDate = serverDate.parseHTTPDate(get(kind));
+ if (parsedDate == null) parsedDate = new Date();
+ return parsedDate;
}
- return prop;
+ return null;
}
- public static Properties parseRequestLine(final String cmd, String args, final Properties prop, final String virtualHost) {
-
- // getting the last request line for debugging purposes
- final String prevRequestLine = prop.containsKey(CONNECTION_PROP_REQUESTLINE)?
- prop.getProperty(CONNECTION_PROP_REQUESTLINE) : "";
-
- // reset property from previous run
- prop.clear();
-
- // storing informations about the request
- prop.setProperty(CONNECTION_PROP_METHOD, cmd);
- prop.setProperty(CONNECTION_PROP_REQUESTLINE,cmd + " " + args);
- prop.setProperty(CONNECTION_PROP_PREV_REQUESTLINE,prevRequestLine);
-
- // this parses a whole URL
- if (args.length() == 0) {
- prop.setProperty(CONNECTION_PROP_HOST, virtualHost);
- prop.setProperty(CONNECTION_PROP_PATH, "/");
- prop.setProperty(CONNECTION_PROP_HTTP_VER, HTTP_VERSION_0_9);
- prop.setProperty(CONNECTION_PROP_EXT, "");
- return prop;
- }
-
- // store the version propery "HTTP" and cut the query at both ends
- int sep = args.lastIndexOf(" ");
- if ((sep >= 0)&&(args.substring(sep + 1).toLowerCase().startsWith("http/"))) {
- // HTTP version is given
- prop.setProperty(CONNECTION_PROP_HTTP_VER, args.substring(sep + 1).trim());
- args = args.substring(0, sep).trim(); // cut off HTTP version mark
- } else {
- // HTTP version is not given, it will be treated as ver 0.9
- prop.setProperty(CONNECTION_PROP_HTTP_VER, HTTP_VERSION_0_9);
- }
-
- // replacing spaces in the url string correctly
- args = args.replace(" ","%20");
- // replace unwise characters (see RFC 2396, 2.4.3), which may not be escaped
- args = args.replace("{", "%7B").replace("}", "%7D").replace("|", "%7C").replace("\\", "%5C")
- .replace("^", "%5E").replace("[", "%5B").replace("]", "%5D").replace("`", "%60");
-
-
- // properties of the query are stored with the prefix "&"
- // additionally, the values URL and ARGC are computed
-
- String argsString = "";
- sep = args.indexOf("?");
- if (sep >= 0) {
- // there are values attached to the query string
- argsString = args.substring(sep + 1); // cut head from tail of query
- args = args.substring(0, sep);
- }
- prop.setProperty(CONNECTION_PROP_URL, args); // store URL
- //System.out.println("HTTPD: ARGS=" + argsString);
- if (argsString.length() != 0) prop.setProperty(CONNECTION_PROP_ARGS, argsString); // store arguments in original form
-
- // finally find host string
- String path;
- if (args.toUpperCase().startsWith("HTTP://")) {
- // a host was given. extract it and set path
- args = args.substring(7);
- sep = args.indexOf("/");
- if (sep < 0) {
- // this is a malformed url, something like
- // http://index.html
- // we are lazy and guess that it means
- // /index.html
- // which is a localhost access to the file servlet
- prop.setProperty(CONNECTION_PROP_HOST, args);
- path = "/";
- } else {
- // THIS IS THE "GOOD" CASE
- // a perfect formulated url
- final String dstHostSocket = args.substring(0, sep);
- prop.setProperty(CONNECTION_PROP_HOST, (httpd.isThisHostName(dstHostSocket)?virtualHost:dstHostSocket));
- path = args.substring(sep); // yes, including beginning "/"
- }
- } else {
- // no host in url. set path
- if (args.startsWith("/")) {
- // thats also fine, its a perfect localhost access
- // in this case, we simulate a
- // http://localhost/s
- // access by setting a virtual host
- prop.setProperty(CONNECTION_PROP_HOST, virtualHost);
- path = args;
- } else {
- // the client 'forgot' to set a leading '/'
- // this is the same case as above, with some lazyness
- prop.setProperty(CONNECTION_PROP_HOST, virtualHost);
- path = "/" + args;
- }
- }
- prop.setProperty(CONNECTION_PROP_PATH, path);
-
- // find out file extension (we already stripped ?-parameters from args)
- String ext = ""; // default when no file extension
- sep = path.lastIndexOf(".");
- if (sep >= 0) {
- final int ancpos = path.indexOf("#", sep + 1);
- if (ancpos >= sep) {
- // ex: /foo/bar.html#xy => html
- ext = path.substring(sep + 1, ancpos).toLowerCase();
- } else {
- // ex: /foo/bar.php => php
- ext = path.substring(sep + 1).toLowerCase();
- }
- }
- prop.setProperty(CONNECTION_PROP_EXT, ext);
-
- return prop;
- }
-
public static boolean supportChunkedEncoding(final Properties conProp) {
// getting the http version of the client
final String httpVer = conProp.getProperty(CONNECTION_PROP_HTTP_VER);
@@ -635,57 +384,6 @@ public final class httpHeader extends TreeMap<String, String> implements Map<Str
return !(httpVer.equals(HTTP_VERSION_0_9) || httpVer.equals(HTTP_VERSION_1_0));
}
- /**
- * Reading http headers from a reader class and building up a httpHeader object
- * @param reader the {@link BufferedReader} that is used to read the http header lines
- * @return a {@link httpHeader}-Object containing all parsed headers
- * @throws IOException
- */
- public static httpHeader readHttpHeader(final BufferedReader reader) throws IOException {
- // reading all request headers
- final httpHeader httpHeader = new httpHeader(httpd.reverseMappingCache);
- int p;
- String line;
- while ((line = reader.readLine()) != null) {
- if (line.length() == 0) break;
- if ((p = line.indexOf(":")) >= 0) {
- // store a property
- httpHeader.add(line.substring(0, p).trim(), line.substring(p + 1).trim());
- }
- }
- return httpHeader;
- }
-
- public static httpHeader readHeader(final Properties prop, final serverCore.Session theSession) throws IOException {
-
- // reading all headers
- final httpHeader header = new httpHeader(httpd.reverseMappingCache);
- int p;
- String line;
- while ((line = theSession.readLineAsString()) != null) {
- if (line.length() == 0) break; // this seperates the header of the HTTP request from the body
- // parse the header line: a property seperated with the ':' sign
- if ((p = line.indexOf(":")) >= 0) {
- // store a property
- header.add(line.substring(0, p).trim(), line.substring(p + 1).trim());
- }
- }
-
- /*
- * doing some header validation here ...
- */
- final String httpVersion = prop.getProperty(httpHeader.CONNECTION_PROP_HTTP_VER, "HTTP/0.9");
- if (httpVersion.equals("HTTP/1.1") && !header.containsKey(httpHeader.HOST)) {
- // the HTTP/1.1 specification requires that an HTTP/1.1 server must reject any
- // HTTP/1.1 message that does not contain a Host header.
- httpd.sendRespondError(prop,theSession.out,0,400,null,null,null);
- throw new IOException("400 Bad request");
- }
-
- return header;
- }
-
-
public StringBuffer toHeaderString(
final String httpVersion,
final int httpStatusCode,
@@ -764,7 +462,7 @@ public final class httpHeader extends TreeMap<String, String> implements Map<Str
return url;
}
- public static void handleTransparentProxySupport(final httpHeader header, final Properties prop, final String virtualHost, final boolean isTransparentProxy) {
+ public static void handleTransparentProxySupport(final httpRequestHeader header, final Properties prop, final String virtualHost, final boolean isTransparentProxy) {
// transparent proxy support is only available for http 1.0 and above connections
if (prop.getProperty(CONNECTION_PROP_HTTP_VER, "HTTP/0.9").equals("HTTP/0.9")) return;
@@ -779,6 +477,28 @@ public final class httpHeader extends TreeMap<String, String> implements Map<Str
final String dstHostSocket = header.get(httpHeader.HOST);
prop.setProperty(CONNECTION_PROP_HOST,(httpd.isThisHostName(dstHostSocket)?virtualHost:dstHostSocket));
}
+
+
+ /**
+ * Reading http headers from a reader class and building up a httpHeader object
+ * @param reader the {@link BufferedReader} that is used to read the http header lines
+ * @return a {@link httpHeader}-Object containing all parsed headers
+ * @throws IOException
+ */
+ public void readHttpHeader(final BufferedReader reader) throws IOException {
+ // reading all request headers
+ int p;
+ String line;
+ while ((line = reader.readLine()) != null) {
+ if (line.length() == 0) break;
+ if ((p = line.indexOf(":")) >= 0) {
+ // store a property
+ add(line.substring(0, p).trim(), line.substring(p + 1).trim());
+ }
+ }
+ }
+
+
/*
* Patch BEGIN:
* Name: Header Property Patch
@@ -941,23 +661,4 @@ public final class httpHeader extends TreeMap<String, String> implements Map<Str
* Patch END:
* Name: Header Property Patch
*/
-
- /**
- * @param header
- * @return a supported Charset, so data can be encoded (may not be correct)
- */
- static Charset getCharSet(final httpHeader header) {
- String charSetName = header.getCharacterEncoding();
- if (charSetName == null) {
- // no character encoding is sent by the server
- charSetName = DEFAULT_CHARSET;
- }
- // maybe the charset is valid but not installed on this computer
- if(!Charset.isSupported(charSetName)) {
- serverLog.logWarning("httpHeader", "charset '"+ charSetName +"' is not supported on this machine, using default ("+ Charset.defaultCharset().name() +")");
- // use system default
- return Charset.defaultCharset();
- }
- return Charset.forName(charSetName);
- }
}
diff --git a/source/de/anomic/http/httpRequestHeader.java b/source/de/anomic/http/httpRequestHeader.java
new file mode 100755
index 000000000..0a562d893
--- /dev/null
+++ b/source/de/anomic/http/httpRequestHeader.java
@@ -0,0 +1,266 @@
+// httpRequestHeader.java
+// -----------------------
+// (C) 2008 by Michael Peter Christen; [email protected]
+// first published on http://yacy.net
+// Frankfurt, Germany, 22.08.2008
+//
+// last major change: $LastChangedDate: 2008-08-20 09:54:56 +0200 (Mi, 20 Aug 2008) $ by $LastChangedBy: danielr $
+// Revision: $LastChangedRevision: 5063 $
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+package de.anomic.http;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import de.anomic.server.serverCore;
+import de.anomic.server.serverDate;
+
+public class httpRequestHeader extends httpHeader {
+
+ // request header properties
+ public static final String ACCEPT = "Accept";
+ public static final String ACCEPT_CHARSET = "Accept-Charset";
+ public static final String ACCEPT_LANGUAGE = "Accept-Language";
+
+ public static final String CONNECTION = "Connection";
+ public static final String PROXY_CONNECTION = "Proxy-Connection";
+ public static final String KEEP_ALIVE = "Keep-Alive";
+
+ public static final String AUTHORIZATION = "Authorization";
+ public static final String WWW_AUTHENTICATE = "WWW-Authenticate";
+ public static final String PROXY_AUTHORIZATION = "Proxy-Authorization";
+ public static final String PROXY_AUTHENTICATE = "Proxy-Authenticate";
+
+ public static final String UPGRADE = "Upgrade";
+ public static final String TE = "TE";
+
+ public static final String X_CACHE = "X-Cache";
+ public static final String X_CACHE_LOOKUP = "X-Cache-Lookup";
+
+ public static final String COOKIE = "Cookie";
+
+ public static final String ACCEPT_ENCODING = "Accept-Encoding";
+ public static final String IF_MODIFIED_SINCE = "If-Modified-Since";
+ public static final String IF_RANGE = "If-Range";
+ public static final String REFERER = "Referer";
+
+ private static final long serialVersionUID = 0L;
+
+ public httpRequestHeader() {
+ super();
+ }
+
+ public httpRequestHeader(final HashMap<String, String> reverseMappingCache) {
+ super(reverseMappingCache);
+ }
+
+ public httpRequestHeader(final HashMap<String, String> reverseMappingCache, final Map<String, String> othermap) {
+ super(reverseMappingCache, othermap);
+ }
+
+ public String referer() {
+ return (String) get(REFERER, "");
+ }
+
+ public String refererHost() {
+ String refererHost = "";
+ final String referer = referer();
+ if (referer.length() > 0) try { refererHost = (new URL(referer)).getHost(); } catch (final MalformedURLException e) {}
+ return refererHost;
+ }
+
+ public Date ifModifiedSince() {
+ return headerDate(IF_MODIFIED_SINCE);
+ }
+
+ public Object ifRange() {
+ if (containsKey(IF_RANGE)) {
+ final Date rangeDate = serverDate.parseHTTPDate(get(IF_RANGE));
+ if (rangeDate != null)
+ return rangeDate;
+
+ return get(IF_RANGE);
+ }
+ return null;
+ }
+
+ public String userAgent() {
+ return (String) get(USER_AGENT, "");
+ }
+
+ public boolean acceptGzip() {
+ return ((containsKey(ACCEPT_ENCODING)) &&
+ ((get(ACCEPT_ENCODING)).toUpperCase().indexOf("GZIP")) != -1);
+ }
+
+ public static Properties parseRequestLine(final String s, final Properties prop, final String virtualHost) {
+ final int p = s.indexOf(" ");
+ if (p >= 0) {
+ final String cmd = s.substring(0,p);
+ final String args = s.substring(p+1);
+ return parseRequestLine(cmd,args, prop,virtualHost);
+ }
+ return prop;
+ }
+
+ public static Properties parseRequestLine(final String cmd, String args, final Properties prop, final String virtualHost) {
+
+ // getting the last request line for debugging purposes
+ final String prevRequestLine = prop.containsKey(CONNECTION_PROP_REQUESTLINE)?
+ prop.getProperty(CONNECTION_PROP_REQUESTLINE) : "";
+
+ // reset property from previous run
+ prop.clear();
+
+ // storing informations about the request
+ prop.setProperty(CONNECTION_PROP_METHOD, cmd);
+ prop.setProperty(CONNECTION_PROP_REQUESTLINE, cmd + " " + args);
+ prop.setProperty(CONNECTION_PROP_PREV_REQUESTLINE, prevRequestLine);
+
+ // this parses a whole URL
+ if (args.length() == 0) {
+ prop.setProperty(CONNECTION_PROP_HOST, virtualHost);
+ prop.setProperty(CONNECTION_PROP_PATH, "/");
+ prop.setProperty(CONNECTION_PROP_HTTP_VER, HTTP_VERSION_0_9);
+ prop.setProperty(CONNECTION_PROP_EXT, "");
+ return prop;
+ }
+
+ // store the version propery "HTTP" and cut the query at both ends
+ int sep = args.lastIndexOf(" ");
+ if ((sep >= 0)&&(args.substring(sep + 1).toLowerCase().startsWith("http/"))) {
+ // HTTP version is given
+ prop.setProperty(CONNECTION_PROP_HTTP_VER, args.substring(sep + 1).trim());
+ args = args.substring(0, sep).trim(); // cut off HTTP version mark
+ } else {
+ // HTTP version is not given, it will be treated as ver 0.9
+ prop.setProperty(CONNECTION_PROP_HTTP_VER, HTTP_VERSION_0_9);
+ }
+
+ // replacing spaces in the url string correctly
+ args = args.replace(" ","%20");
+ // replace unwise characters (see RFC 2396, 2.4.3), which may not be escaped
+ args = args.replace("{", "%7B").replace("}", "%7D").replace("|", "%7C").replace("\\", "%5C")
+ .replace("^", "%5E").replace("[", "%5B").replace("]", "%5D").replace("`", "%60");
+
+
+ // properties of the query are stored with the prefix "&"
+ // additionally, the values URL and ARGC are computed
+
+ String argsString = "";
+ sep = args.indexOf("?");
+ if (sep >= 0) {
+ // there are values attached to the query string
+ argsString = args.substring(sep + 1); // cut head from tail of query
+ args = args.substring(0, sep);
+ }
+ prop.setProperty(CONNECTION_PROP_URL, args); // store URL
+ //System.out.println("HTTPD: ARGS=" + argsString);
+ if (argsString.length() != 0) prop.setProperty(CONNECTION_PROP_ARGS, argsString); // store arguments in original form
+
+ // finally find host string
+ String path;
+ if (args.toUpperCase().startsWith("HTTP://")) {
+ // a host was given. extract it and set path
+ args = args.substring(7);
+ sep = args.indexOf("/");
+ if (sep < 0) {
+ // this is a malformed url, something like
+ // http://index.html
+ // we are lazy and guess that it means
+ // /index.html
+ // which is a localhost access to the file servlet
+ prop.setProperty(CONNECTION_PROP_HOST, args);
+ path = "/";
+ } else {
+ // THIS IS THE "GOOD" CASE
+ // a perfect formulated url
+ final String dstHostSocket = args.substring(0, sep);
+ prop.setProperty(CONNECTION_PROP_HOST, (httpd.isThisHostName(dstHostSocket)?virtualHost:dstHostSocket));
+ path = args.substring(sep); // yes, including beginning "/"
+ }
+ } else {
+ // no host in url. set path
+ if (args.startsWith("/")) {
+ // thats also fine, its a perfect localhost access
+ // in this case, we simulate a
+ // http://localhost/s
+ // access by setting a virtual host
+ prop.setProperty(CONNECTION_PROP_HOST, virtualHost);
+ path = args;
+ } else {
+ // the client 'forgot' to set a leading '/'
+ // this is the same case as above, with some lazyness
+ prop.setProperty(CONNECTION_PROP_HOST, virtualHost);
+ path = "/" + args;
+ }
+ }
+ prop.setProperty(CONNECTION_PROP_PATH, path);
+
+ // find out file extension (we already stripped ?-parameters from args)
+ String ext = ""; // default when no file extension
+ sep = path.lastIndexOf(".");
+ if (sep >= 0) {
+ final int ancpos = path.indexOf("#", sep + 1);
+ if (ancpos >= sep) {
+ // ex: /foo/bar.html#xy => html
+ ext = path.substring(sep + 1, ancpos).toLowerCase();
+ } else {
+ // ex: /foo/bar.php => php
+ ext = path.substring(sep + 1).toLowerCase();
+ }
+ }
+ prop.setProperty(CONNECTION_PROP_EXT, ext);
+
+ return prop;
+ }
+
+ public static httpRequestHeader readHeader(final Properties prop, final serverCore.Session theSession) throws IOException {
+
+ // reading all headers
+ final httpRequestHeader header = new httpRequestHeader(httpd.reverseMappingCache);
+ int p;
+ String line;
+ while ((line = theSession.readLineAsString()) != null) {
+ if (line.length() == 0) break; // this separates the header of the HTTP request from the body
+ // parse the header line: a property separated with the ':' sign
+ if ((p = line.indexOf(":")) >= 0) {
+ // store a property
+ header.add(line.substring(0, p).trim(), line.substring(p + 1).trim());
+ }
+ }
+
+ /*
+ * doing some header validation here ...
+ */
+ final String httpVersion = prop.getProperty(httpHeader.CONNECTION_PROP_HTTP_VER, "HTTP/0.9");
+ if (httpVersion.equals("HTTP/1.1") && !header.containsKey(httpHeader.HOST)) {
+ // the HTTP/1.1 specification requires that an HTTP/1.1 server must reject any
+ // HTTP/1.1 message that does not contain a Host header.
+ httpd.sendRespondError(prop,theSession.out,0,400,null,null,null);
+ throw new IOException("400 Bad request");
+ }
+
+ return header;
+ }
+
+}
diff --git a/source/de/anomic/http/httpResponseHeader.java b/source/de/anomic/http/httpResponseHeader.java
new file mode 100755
index 000000000..5049c949d
--- /dev/null
+++ b/source/de/anomic/http/httpResponseHeader.java
@@ -0,0 +1,139 @@
+// httpResponseHeader.java
+// -----------------------
+// (C) 2008 by Michael Peter Christen; [email protected]
+// first published on http://yacy.net
+// Frankfurt, Germany, 22.08.2008
+//
+// last major change: $LastChangedDate: 2008-08-20 09:54:56 +0200 (Mi, 20 Aug 2008) $ by $LastChangedBy: danielr $
+// Revision: $LastChangedRevision: 5063 $
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+package de.anomic.http;
+
+import java.nio.charset.Charset;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+import de.anomic.server.logging.serverLog;
+
+public class httpResponseHeader extends httpHeader {
+
+ // response header properties
+ public static final String X_YACY_PREVIOUS_REQUEST_LINE = "X-Previous-Request-Line";
+ public static final String X_YACY_KEEP_ALIVE_REQUEST_COUNT = "X-Keep-Alive-Request-Count";
+ public static final String X_YACY_ORIGINAL_REQUEST_LINE = "X-Original-Request-Line";
+
+ public static final String SET_COOKIE = "Set-Cookie";
+ public static final String SET_COOKIE2 = "Set-Cookie2";
+ public static final String EXPIRES = "Expires";
+
+ public static final String LAST_MODIFIED = "Last-modified";
+
+ private static final long serialVersionUID = 0L;
+
+ public httpResponseHeader() {
+ super();
+ }
+
+ public httpResponseHeader(final HashMap<String, String> reverseMappingCache) {
+ super(reverseMappingCache);
+ }
+
+ public httpResponseHeader(final HashMap<String, String> reverseMappingCache, final Map<String, String> othermap) {
+ super(reverseMappingCache, othermap);
+ }
+
+
+
+ public Date date() {
+ return headerDate(httpHeader.DATE);
+ }
+
+ public Date expires() {
+ return headerDate(EXPIRES);
+ }
+
+ public Date lastModified() {
+ Date d = headerDate(LAST_MODIFIED);
+ if (d == null) return new Date(); else return d;
+ }
+
+ public long age() {
+ final Date lm = lastModified();
+ final Date sd = date();
+ if (lm == null) return Long.MAX_VALUE;
+ return ((sd == null) ? new Date() : sd).getTime() - lm.getTime();
+ }
+
+ public boolean gzip() {
+ return ((containsKey(CONTENT_ENCODING)) &&
+ ((get(CONTENT_ENCODING)).toUpperCase().startsWith("GZIP")));
+ }
+
+ public static Object[] parseResponseLine(final String respLine) {
+
+ if ((respLine == null) || (respLine.length() == 0)) {
+ return new Object[]{"HTTP/1.0",Integer.valueOf(500),"status line parse error"};
+ }
+
+ int p = respLine.indexOf(" ");
+ if (p < 0) {
+ return new Object[]{"HTTP/1.0",Integer.valueOf(500),"status line parse error"};
+ }
+
+ String httpVer, status, statusText;
+ Integer statusCode;
+
+ // the http version reported by the server
+ httpVer = respLine.substring(0,p);
+
+ // Status of the request, e.g. "200 OK"
+ status = respLine.substring(p + 1).trim(); // the status code plus reason-phrase
+
+ // splitting the status into statuscode and statustext
+ p = status.indexOf(" ");
+ try {
+ statusCode = Integer.valueOf((p < 0) ? status.trim() : status.substring(0,p).trim());
+ statusText = (p < 0) ? "" : status.substring(p+1).trim();
+ } catch (final Exception e) {
+ statusCode = Integer.valueOf(500);
+ statusText = status;
+ }
+
+ return new Object[]{httpVer,statusCode,statusText};
+ }
+
+
+ /**
+ * @param header
+ * @return a supported Charset, so data can be encoded (may not be correct)
+ */
+ public Charset getCharSet() {
+ String charSetName = getCharacterEncoding();
+ if (charSetName == null) {
+ // no character encoding is sent by the server
+ charSetName = DEFAULT_CHARSET;
+ }
+ // maybe the charset is valid but not installed on this computer
+ if(!Charset.isSupported(charSetName)) {
+ serverLog.logWarning("httpHeader", "charset '"+ charSetName +"' is not supported on this machine, using default ("+ Charset.defaultCharset().name() +")");
+ // use system default
+ return Charset.defaultCharset();
+ }
+ return Charset.forName(charSetName);
+ }
+}
diff --git a/source/de/anomic/http/httpSSI.java b/source/de/anomic/http/httpSSI.java
index 64ca09463..13b9c4cf5 100644
--- a/source/de/anomic/http/httpSSI.java
+++ b/source/de/anomic/http/httpSSI.java
@@ -80,13 +80,13 @@ public class httpSSI {
// set up virtual connection properties to call httpdFileHander.doGet()
final Properties conProp = new Properties();
- final httpHeader header = new httpHeader(httpd.reverseMappingCache);
+ final httpRequestHeader header = new httpRequestHeader(httpd.reverseMappingCache);
conProp.setProperty(httpHeader.CONNECTION_PROP_METHOD, httpHeader.METHOD_GET);
conProp.setProperty(httpHeader.CONNECTION_PROP_PATH, path);
conProp.setProperty(httpHeader.CONNECTION_PROP_ARGS, args);
conProp.setProperty(httpHeader.CONNECTION_PROP_HTTP_VER, httpHeader.HTTP_VERSION_0_9);
conProp.setProperty(httpHeader.CONNECTION_PROP_CLIENTIP, requesthost);
- header.put(httpHeader.AUTHORIZATION, authorization);
+ header.put(httpRequestHeader.AUTHORIZATION, authorization);
httpdFileHandler.doGet(conProp, header, out);
}
}
diff --git a/source/de/anomic/http/httpd.java b/source/de/anomic/http/httpd.java
index 35b04e091..399bf8ed9 100644
--- a/source/de/anomic/http/httpd.java
+++ b/source/de/anomic/http/httpd.java
@@ -43,6 +43,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
import java.util.StringTokenizer;
import java.util.Map.Entry;
@@ -250,36 +251,36 @@ public final class httpd implements serverHandler, Cloneable {
* @param header the received http-headers
* @return <code>true</code> if a persistent connection was requested or <code>false</code> otherwise
*/
- private boolean handlePersistentConnection(final httpHeader header) {
+ private boolean handlePersistentConnection(final httpRequestHeader header) {
if (!keepAliveSupport) {
- this.prop.put(httpHeader.CONNECTION_PROP_PERSISTENT,"close");
+ this.prop.put(httpRequestHeader.CONNECTION_PROP_PERSISTENT,"close");
return false;
}
// getting the http version that is used by the client
- final String httpVersion = this.prop.getProperty(httpHeader.CONNECTION_PROP_HTTP_VER, "HTTP/0.9");
+ final String httpVersion = this.prop.getProperty(httpRequestHeader.CONNECTION_PROP_HTTP_VER, "HTTP/0.9");
// managing keep-alive: in HTTP/0.9 and HTTP/1.0 every connection is closed
// afterwards. In HTTP/1.1 (and above, in the future?) connections are
// persistent by default, but closed with the "Connection: close"
// property.
- boolean persistent = !(httpVersion.equals(httpHeader.HTTP_VERSION_0_9) || httpVersion.equals(httpHeader.HTTP_VERSION_1_0));
- if (((String)header.get(httpHeader.CONNECTION, "keep-alive")).toLowerCase().indexOf("close") != -1 ||
- ((String)header.get(httpHeader.PROXY_CONNECTION, "keep-alive")).toLowerCase().indexOf("close") != -1) {
+ boolean persistent = !(httpVersion.equals(httpRequestHeader.HTTP_VERSION_0_9) || httpVersion.equals(httpRequestHeader.HTTP_VERSION_1_0));
+ if (((String)header.get(httpRequestHeader.CONNECTION, "keep-alive")).toLowerCase().indexOf("close") != -1 ||
+ ((String)header.get(httpRequestHeader.PROXY_CONNECTION, "keep-alive")).toLowerCase().indexOf("close") != -1) {
persistent = false;
}
final String transferEncoding = (String) header.get(httpHeader.TRANSFER_ENCODING, "identity");
- final boolean isPostRequest = this.prop.getProperty(httpHeader.CONNECTION_PROP_METHOD).equals(httpHeader.METHOD_POST);
+ final boolean isPostRequest = this.prop.getProperty(httpRequestHeader.CONNECTION_PROP_METHOD).equals(httpRequestHeader.METHOD_POST);
final boolean hasContentLength = header.containsKey(httpHeader.CONTENT_LENGTH);
final boolean hasTransferEncoding = header.containsKey(httpHeader.TRANSFER_ENCODING) && !transferEncoding.equalsIgnoreCase("identity");
// if the request does not contain a content-length we have to close the connection
// independently of the value of the connection header
if (persistent && isPostRequest && !(hasContentLength || hasTransferEncoding))
- this.prop.put(httpHeader.CONNECTION_PROP_PERSISTENT,"close");
- else this.prop.put(httpHeader.CONNECTION_PROP_PERSISTENT,persistent?"keep-alive":"close");
+ this.prop.put(httpRequestHeader.CONNECTION_PROP_PERSISTENT,"close");
+ else this.prop.put(httpRequestHeader.CONNECTION_PROP_PERSISTENT,persistent?"keep-alive":"close");
return persistent;
}
@@ -294,31 +295,31 @@ public final class httpd implements serverHandler, Cloneable {
return 1;
}
- private boolean handleServerAuthentication(final httpHeader header) throws IOException {
+ private boolean handleServerAuthentication(final httpRequestHeader header) throws IOException {
// getting the http version that is used by the client
- final String httpVersion = this.prop.getProperty(httpHeader.CONNECTION_PROP_HTTP_VER, "HTTP/0.9");
+ final String httpVersion = this.prop.getProperty(httpRequestHeader.CONNECTION_PROP_HTTP_VER, "HTTP/0.9");
// reading the authentication settings from switchboard
if (this.serverAccountBase64MD5 == null)
this.serverAccountBase64MD5 = switchboard.getConfig("serverAccountBase64MD5", "");
if (this.serverAccountBase64MD5.length() > 0) {
- final String auth = header.get(httpHeader.AUTHORIZATION);
+ final String auth = header.get(httpRequestHeader.AUTHORIZATION);
if (auth == null) {
// authorization requested, but no authorizeation given in header. Ask for authenticate:
this.session.out.write((httpVersion + " 401 log-in required" + serverCore.CRLF_STRING +
- httpHeader.WWW_AUTHENTICATE + ": Basic realm=\"log-in\"" + serverCore.CRLF_STRING +
+ httpRequestHeader.WWW_AUTHENTICATE + ": Basic realm=\"log-in\"" + serverCore.CRLF_STRING +
serverCore.CRLF_STRING).getBytes());
- this.session.out.write((httpHeader.CONTENT_LENGTH + ": 0\r\n").getBytes());
+ this.session.out.write((httpResponseHeader.CONTENT_LENGTH + ": 0\r\n").getBytes());
this.session.out.write("\r\n".getBytes());
return false;
} else if (!this.serverAccountBase64MD5.equals(serverCodings.encodeMD5Hex(auth.trim().substring(6)))) {
// wrong password given: ask for authenticate again
log.logInfo("Wrong log-in for account 'server' in HTTPD.GET " + this.prop.getProperty("PATH") + " from IP " + this.clientIP);
this.session.out.write((httpVersion + " 401 log-in required" + serverCore.CRLF_STRING +
- httpHeader.WWW_AUTHENTICATE + ": Basic realm=\"log-in\"" +
+ httpRequestHeader.WWW_AUTHENTICATE + ": Basic realm=\"log-in\"" +
serverCore.CRLF_STRING).getBytes());
- this.session.out.write((httpHeader.CONTENT_LENGTH + ": 0\r\n").getBytes());
+ this.session.out.write((httpResponseHeader.CONTENT_LENGTH + ": 0\r\n").getBytes());
this.session.out.write("\r\n".getBytes());
this.session.out.flush();
return false;
@@ -327,14 +328,14 @@ public final class httpd implements serverHandler, Cloneable {
return true;
}
- private boolean handleYaCyHopAuthentication(final httpHeader header) {
+ private boolean handleYaCyHopAuthentication(final httpRequestHeader header) {
// check if the user has allowed that his/her peer is used for hops
if (!this.allowYaCyHop) return false;
// proxy hops must identify with 4 criteria:
// the accessed port must not be port 80
- final String host = this.prop.getProperty(httpHeader.CONNECTION_PROP_HOST);
+ final String host = this.prop.getProperty(httpRequestHeader.CONNECTION_PROP_HOST);
if (host == null) return false;
int pos;
if ((pos = host.indexOf(":")) < 0) {
@@ -344,24 +345,24 @@ public final class httpd implements serverHandler, Cloneable {
if (Integer.parseInt(host.substring(pos + 1)) == 80) return false;
// the access path must be into the yacy protocol path; it must start with 'yacy'
- if (!(this.prop.getProperty(httpHeader.CONNECTION_PROP_PATH, "").startsWith("/yacy/"))) return false;
+ if (!(this.prop.getProperty(httpRequestHeader.CONNECTION_PROP_PATH, "").startsWith("/yacy/"))) return false;
// the accessing client must identify with user:password, where
// user = addressed peer name
// pw = addressed peer hash (b64-hash)
- final String auth = (String) header.get(httpHeader.PROXY_AUTHORIZATION,"xxxxxx");
+ final String auth = (String) header.get(httpRequestHeader.PROXY_AUTHORIZATION,"xxxxxx");
if (getAlternativeResolver() != null) {
final String test = kelondroBase64Order.standardCoder.encodeString(getAlternativeResolver().myName() + ":" + getAlternativeResolver().myID());
if (!test.equals(auth.trim().substring(6))) return false;
}
// the accessing client must use a yacy user-agent
- if (!(((String) header.get(httpHeader.USER_AGENT,"")).startsWith("yacy"))) return false;
+ if (!(((String) header.get(httpRequestHeader.USER_AGENT,"")).startsWith("yacy"))) return false;
// furthermore, YaCy hops must not exceed a specific access frequency
// check access requester frequency: protection against DoS against this peer
- final String requester = this.prop.getProperty(httpHeader.CONNECTION_PROP_CLIENTIP);
+ final String requester = this.prop.getProperty(httpRequestHeader.CONNECTION_PROP_CLIENTIP);
if (requester == null) return false;
if (lastAccessDelta(YaCyHopAccessRequester, requester) < 10000) return false;
YaCyHopAccessRequester.put(requester, Long.valueOf(System.currentTimeMillis()));
@@ -380,7 +381,7 @@ public final class httpd implements serverHandler, Cloneable {
return System.currentTimeMillis() - lastAccess.longValue();
}
- private boolean handleProxyAuthentication(final httpHeader header) throws IOException {
+ private boolean handleProxyAuthentication(final httpRequestHeader header) throws IOException {
// getting the http version that is used by the client
final String httpVersion = this.prop.getProperty("HTTP", "HTTP/0.9");
@@ -391,7 +392,7 @@ public final class httpd implements serverHandler, Cloneable {
}
if (this.use_proxyAccounts) {
- final String auth = (String) header.get(httpHeader.PROXY_AUTHORIZATION,"xxxxxx");
+ final String auth = (String) header.get(httpRequestHeader.PROXY_AUTHORIZATION,"xxxxxx");
userDB.Entry entry=switchboard.userDB.ipAuth(this.clientIP);
if(entry == null){
entry=switchboard.userDB.proxyAuth(auth, this.clientIP);
@@ -414,8 +415,8 @@ public final class httpd implements serverHandler, Cloneable {
}
// ask for authenticate
this.session.out.write((httpVersion + " 407 Proxy Authentication Required" + serverCore.CRLF_STRING +
- httpHeader.PROXY_AUTHENTICATE + ": Basic realm=\"log-in\"" + serverCore.CRLF_STRING).getBytes());
- this.session.out.write((httpHeader.CONTENT_LENGTH + ": 0\r\n").getBytes());
+ httpRequestHeader.PROXY_AUTHENTICATE + ": Basic realm=\"log-in\"" + serverCore.CRLF_STRING).getBytes());
+ this.session.out.write((httpResponseHeader.CONTENT_LENGTH + ": 0\r\n").getBytes());
this.session.out.write("\r\n".getBytes());
this.session.out.flush();
return false;
@@ -437,7 +438,6 @@ public final class httpd implements serverHandler, Cloneable {
}
parseRequestLine(unknownCommand, args);
- //String httpVersion = this.prop.getProperty(httpHeader.CONNECTION_PROP_HTTP_VER,"HTTP/0.9");
sendRespondError(this.prop,this.session.out,0,501,null,unknownCommand + " method not implemented",null);
return serverCore.TERMINATE_CONNECTION;
@@ -462,21 +462,21 @@ public final class httpd implements serverHandler, Cloneable {
public Boolean GET(final String arg) {
try {
// parsing the http request line
- parseRequestLine(httpHeader.METHOD_GET,arg);
+ parseRequestLine(httpRequestHeader.METHOD_GET,arg);
// we now know the HTTP version. depending on that, we read the header
- final String httpVersion = this.prop.getProperty(httpHeader.CONNECTION_PROP_HTTP_VER, httpHeader.HTTP_VERSION_0_9);
- final httpHeader header = (httpVersion.equals(httpHeader.HTTP_VERSION_0_9))
- ? new httpHeader(reverseMappingCache)
- : httpHeader.readHeader(this.prop,this.session);
+ final String httpVersion = this.prop.getProperty(httpRequestHeader.CONNECTION_PROP_HTTP_VER, httpRequestHeader.HTTP_VERSION_0_9);
+ final httpRequestHeader header = (httpVersion.equals(httpRequestHeader.HTTP_VERSION_0_9))
+ ? new httpRequestHeader(reverseMappingCache)
+ : httpRequestHeader.readHeader(this.prop,this.session);
// handling transparent proxy support
- httpHeader.handleTransparentProxySupport(header, this.prop, virtualHost, httpdProxyHandler.isTransparentProxy);
+ httpRequestHeader.handleTransparentProxySupport(header, this.prop, virtualHost, httpdProxyHandler.isTransparentProxy);
// determines if the connection should be kept alive
handlePersistentConnection(header);
- if (this.prop.getProperty(httpHeader.CONNECTION_PROP_HOST).equals(virtualHost)) {
+ if (this.prop.getProperty(httpRequestHeader.CONNECTION_PROP_HOST).equals(virtualHost)) {
// pass to server
if (this.allowServer) {
if (this.handleServerAuthentication(header)) {
@@ -499,7 +499,7 @@ public final class httpd implements serverHandler, Cloneable {
}
}
- return this.prop.getProperty(httpHeader.CONNECTION_PROP_PERSISTENT).equals("keep-alive") ? serverCore.RESUME_CONNECTION : serverCore.TERMINATE_CONNECTION;
+ return this.prop.getProperty(httpRequestHeader.CONNECTION_PROP_PERSISTENT).equals("keep-alive") ? serverCore.RESUME_CONNECTION : serverCore.TERMINATE_CONNECTION;
} catch (final Exception e) {
logUnexpectedError(e);
return serverCore.TERMINATE_CONNECTION;
@@ -532,22 +532,22 @@ public final class httpd implements serverHandler, Cloneable {
public Boolean HEAD(final String arg) {
try {
- parseRequestLine(httpHeader.METHOD_HEAD,arg);
+ parseRequestLine(httpRequestHeader.METHOD_HEAD,arg);
// we now know the HTTP version. depending on that, we read the header
- httpHeader header;
- final String httpVersion = this.prop.getProperty(httpHeader.CONNECTION_PROP_HTTP_VER, httpHeader.HTTP_VERSION_0_9);
- if (httpVersion.equals(httpHeader.HTTP_VERSION_0_9)) header = new httpHeader(reverseMappingCache);
- else header = httpHeader.readHeader(this.prop,this.session);
+ httpRequestHeader header;
+ final String httpVersion = this.prop.getProperty(httpRequestHeader.CONNECTION_PROP_HTTP_VER, httpRequestHeader.HTTP_VERSION_0_9);
+ if (httpVersion.equals(httpRequestHeader.HTTP_VERSION_0_9)) header = new httpRequestHeader(reverseMappingCache);
+ else header = httpRequestHeader.readHeader(this.prop,this.session);
// handle transparent proxy support
- httpHeader.handleTransparentProxySupport(header, this.prop, virtualHost, httpdProxyHandler.isTransparentProxy);
+ httpRequestHeader.handleTransparentProxySupport(header, this.prop, virtualHost, httpdProxyHandler.isTransparentProxy);
// determines if the connection should be kept alive
handlePersistentConnection(header);
// return multi-line message
- if (this.prop.getProperty(httpHeader.CONNECTION_PROP_HOST).equals(virtualHost)) {
+ if (this.prop.getProperty(httpRequestHeader.CONNECTION_PROP_HOST).equals(virtualHost)) {
// pass to server
if (allowServer) {
if (handleServerAuthentication(header)) {
@@ -571,7 +571,7 @@ public final class httpd implements serverHandler, Cloneable {
return serverCore.TERMINATE_CONNECTION;
}
}
- return this.prop.getProperty(httpHeader.CONNECTION_PROP_PERSISTENT).equals("keep-alive") ? serverCore.RESUME_CONNECTION : serverCore.TERMINATE_CONNECTION;
+ return this.prop.getProperty(httpRequestHeader.CONNECTION_PROP_PERSISTENT).equals("keep-alive") ? serverCore.RESUME_CONNECTION : serverCore.TERMINATE_CONNECTION;
} catch (final Exception e) {
logUnexpectedError(e);
return serverCore.TERMINATE_CONNECTION;
@@ -582,22 +582,22 @@ public final class httpd implements serverHandler, Cloneable {
public Boolean POST(final String arg) {
try {
- parseRequestLine(httpHeader.METHOD_POST,arg);
+ parseRequestLine(httpRequestHeader.METHOD_POST,arg);
// we now know the HTTP version. depending on that, we read the header
- httpHeader header;
- final String httpVersion = this.prop.getProperty(httpHeader.CONNECTION_PROP_HTTP_VER, httpHeader.HTTP_VERSION_0_9);
- if (httpVersion.equals(httpHeader.HTTP_VERSION_0_9)) header = new httpHeader(reverseMappingCache);
- else header = httpHeader.readHeader(this.prop,this.session);
+ httpRequestHeader header;
+ final String httpVersion = this.prop.getProperty(httpRequestHeader.CONNECTION_PROP_HTTP_VER, httpRequestHeader.HTTP_VERSION_0_9);
+ if (httpVersion.equals(httpHeader.HTTP_VERSION_0_9)) header = new httpRequestHeader(reverseMappingCache);
+ else header = httpRequestHeader.readHeader(this.prop,this.session);
// handle transfer-coding
final InputStream sessionIn;
- final String transferEncoding = header.get(httpHeader.TRANSFER_ENCODING);
+ final String transferEncoding = header.get(httpRequestHeader.TRANSFER_ENCODING);
if (transferEncoding != null) {
- if (!httpHeader.HTTP_VERSION_1_1.equals(httpVersion)) {
+ if (!httpRequestHeader.HTTP_VERSION_1_1.equals(httpVersion)) {
log.logWarning("client "+ session.getName() +" uses transfer-coding with HTTP version "+ httpVersion +"!");
}
- if("chunked".equalsIgnoreCase(header.get(httpHeader.TRANSFER_ENCODING))) {
+ if("chunked".equalsIgnoreCase(header.get(httpRequestHeader.TRANSFER_ENCODING))) {
sessionIn = new ChunkedInputStream(this.session.in);
} else {
// "A server which receives an entity-body with a transfer-coding it does
@@ -611,13 +611,13 @@ public final class httpd implements serverHandler, Cloneable {
}
// handle transparent proxy support
- httpHeader.handleTransparentProxySupport(header, this.prop, virtualHost, httpdProxyHandler.isTransparentProxy);
+ httpRequestHeader.handleTransparentProxySupport(header, this.prop, virtualHost, httpdProxyHandler.isTransparentProxy);
// determines if the connection should be kept alive
handlePersistentConnection(header);
// return multi-line message
- if (prop.getProperty(httpHeader.CONNECTION_PROP_HOST).equals(virtualHost)) {
+ if (prop.getProperty(httpRequestHeader.CONNECTION_PROP_HOST).equals(virtualHost)) {
// pass to server
if (allowServer) {
if (handleServerAuthentication(header)) {
@@ -640,7 +640,7 @@ public final class httpd implements serverHandler, Cloneable {
}
}
//return serverCore.RESUME_CONNECTION;
- return this.prop.getProperty(httpHeader.CONNECTION_PROP_PERSISTENT).equals("keep-alive") ? serverCore.RESUME_CONNECTION : serverCore.TERMINATE_CONNECTION;
+ return this.prop.getProperty(httpRequestHeader.CONNECTION_PROP_PERSISTENT).equals("keep-alive") ? serverCore.RESUME_CONNECTION : serverCore.TERMINATE_CONNECTION;
} catch (final Exception e) {
logUnexpectedError(e);
return serverCore.TERMINATE_CONNECTION;
@@ -661,10 +661,10 @@ public final class httpd implements serverHandler, Cloneable {
httpVersion = arg.substring(pos + 1);
arg = arg.substring(0, pos);
}
- prop.setProperty(httpHeader.CONNECTION_PROP_HTTP_VER, httpVersion);
+ prop.setProperty(httpRequestHeader.CONNECTION_PROP_HTTP_VER, httpVersion);
// parse hostname and port
- prop.setProperty(httpHeader.CONNECTION_PROP_HOST, arg);
+ prop.setProperty(httpRequestHeader.CONNECTION_PROP_HOST, arg);
pos = arg.indexOf(":");
int port = 443;
if (pos >= 0) {
@@ -673,14 +673,14 @@ public final class httpd implements serverHandler, Cloneable {
}
// setting other connection properties
- prop.setProperty(httpHeader.CONNECTION_PROP_CLIENTIP, this.clientIP);
- prop.setProperty(httpHeader.CONNECTION_PROP_METHOD, httpHeader.METHOD_CONNECT);
- prop.setProperty(httpHeader.CONNECTION_PROP_PATH, "/");
- prop.setProperty(httpHeader.CONNECTION_PROP_EXT, "");
- prop.setProperty(httpHeader.CONNECTION_PROP_URL, "");
+ prop.setProperty(httpRequestHeader.CONNECTION_PROP_CLIENTIP, this.clientIP);
+ prop.setProperty(httpRequestHeader.CONNECTION_PROP_METHOD, httpHeader.METHOD_CONNECT);
+ prop.setProperty(httpRequestHeader.CONNECTION_PROP_PATH, "/");
+ prop.setProperty(httpRequestHeader.CONNECTION_PROP_EXT, "");
+ prop.setProperty(httpRequestHeader.CONNECTION_PROP_URL, "");
// parse remaining lines
- final httpHeader header = httpHeader.readHeader(this.prop,this.session);
+ final httpRequestHeader header = httpRequestHeader.readHeader(this.prop,this.session);
if (!(allowProxy)) {
// not authorized through firewall blocking (ip does not match filter)
@@ -711,21 +711,21 @@ public final class httpd implements serverHandler, Cloneable {
private final void parseRequestLine(final String cmd, final String s) {
// parsing the header
- httpHeader.parseRequestLine(cmd,s,this.prop,virtualHost);
+ httpRequestHeader.parseRequestLine(cmd,s,this.prop,virtualHost);
// track the request
- final String path = this.prop.getProperty(httpHeader.CONNECTION_PROP_URL);
- final String args = this.prop.getProperty(httpHeader.CONNECTION_PROP_ARGS, "");
+ final String path = this.prop.getProperty(httpRequestHeader.CONNECTION_PROP_URL);
+ final String args = this.prop.getProperty(httpRequestHeader.CONNECTION_PROP_ARGS, "");
switchboard.track(this.userAddress.getHostName(), (args.length() > 0) ? path + "?" + args : path);
// reseting the empty request counter
this.emptyRequestCount = 0;
// counting the amount of received requests within this permanent connection
- this.prop.setProperty(httpHeader.CONNECTION_PROP_KEEP_ALIVE_COUNT, Integer.toString(++this.keepAliveRequestCount));
+ this.prop.setProperty(httpRequestHeader.CONNECTION_PROP_KEEP_ALIVE_COUNT, Integer.toString(++this.keepAliveRequestCount));
// setting the client-IP
- this.prop.setProperty(httpHeader.CONNECTION_PROP_CLIENTIP, this.clientIP);
+ this.prop.setProperty(httpRequestHeader.CONNECTION_PROP_CLIENTIP, this.clientIP);
}
// some static methods that needs to be used from any CGI
@@ -882,7 +882,7 @@ public final class httpd implements serverHandler, Cloneable {
* @throws IOException
*/
@SuppressWarnings("unchecked")
- public static HashMap<String, byte[]> parseMultipart(final httpHeader header, final serverObjects args, final InputStream in, final int length)
+ public static HashMap<String, byte[]> parseMultipart(final httpRequestHeader header, final serverObjects args, final InputStream in, final int length)
throws IOException {
RequestContext request = new yacyContextRequest(header, in);
@@ -927,164 +927,6 @@ public final class httpd implements serverHandler, Cloneable {
return files;
}
-// // FIXME this is a quick hack using a previously coded parseMultipart based on a buffer
-// // should be replaced sometime by a 'right' implementation
-//
-// byte[] buffer = null;
-//
-// // parsing post request bodies with a given length
-// if (length != -1) {
-// buffer = new byte[length];
-// int c, a = 0;
-// while (a < length) {
-// c = in.read(buffer, a, length - a);
-// if (c <= 0) break;
-// a += c;
-// }
-// // parsing post request bodies which are gzip content-encoded
-// } else {
-// serverByteBuffer bout = new serverByteBuffer();
-// serverFileUtils.copy(in,bout);
-// buffer = bout.getBytes();
-// bout.close(); bout = null;
-// }
-//
-// //System.out.println("MULTIPART-BUFFER=" + new String(buffer));
-// final HashMap<String, byte[]> files = parseMultipart(header, args, buffer);
-// buffer = null;
-// return files;
-// }
-//
-// public static HashMap<String, byte[]> parseMultipart(final httpHeader header, final serverObjects args, final byte[] buffer) throws IOException {
-// // we parse a multipart message and put results into the properties
-// // find/identify boundary marker
-// //System.out.println("DEBUG parseMultipart = <<" + new String(buffer) + ">>");
-// final String s = header.get(httpHeader.CONTENT_TYPE);
-// if (s == null) return null;
-// int q;
-// int p = s.toLowerCase().indexOf("boundary=");
-// if (p < 0) throw new IOException("boundary marker in multipart not found");
-// // boundaries start with additional leading "--", see RFC1867
-// final byte[] boundary = ("--" + s.substring(p + 9)).getBytes();
-//
-// // eat up first boundary
-// // the buffer must start with a boundary
-// byte[] line = readLine(0, buffer);
-// int pos = nextPos;
-// if ((line == null) || (!(equals(line, 0, boundary, 0, boundary.length))))
-// throw new IOException("boundary not recognized: " + ((line == null) ? "NULL" : new String(line, "UTF-8")) + ", boundary = " + new String(boundary));
-//
-// // we need some constants
-// final byte[] namec = "name=".getBytes();
-// final byte[] filenamec = "filename=".getBytes();
-// //byte[] semicolonc = (new String(";")).getBytes();
-// final byte[] quotec = new byte[] {(byte) '"'};
-//
-// // now loop over boundaries
-// byte [] name;
-// byte [] filename;
-// final HashMap<String, byte[]> files = new HashMap<String, byte[]>();
-// int argc = 0;
-// //System.out.println("DEBUG: parsing multipart body:" + new String(buffer));
-// while (pos < buffer.length) { // boundary enumerator
-// // here the 'pos' marker points to the first line in a section after a boundary line
-// line = readLine(pos, buffer); pos = nextPos;
-// // termination if line is empty
-// if (line.length == 0) break;
-// // find name tag in line
-// p = indexOf(0, line, namec);
-// if (p < 0) throw new IOException("tag name in marker section not found: '" + new String(line, "UTF-8") + "'"); // a name tag must always occur
-// p += namec.length + 1; // first position of name value
-// q = indexOf(p, line, quotec);
-// if (q < 0) throw new IOException("missing quote in name tag: '" + new String(line, "UTF-8") + "'");
-// name = new byte[q - p];
-// java.lang.System.arraycopy(line, p, name, 0, q - p);
-// // if this line has also a filename attribute, read it
-// p = indexOf(q, line, filenamec);
-// if (p > 0) {
-// p += filenamec.length + 1; // first position of name value
-// q = indexOf(p, line, quotec);
-// if (q < 0) {
-// log.logWarning("quote of filename tag not found, searching in next line");
-// // append next line to this
-// final byte[] nextline = readLine(pos, buffer); pos = nextPos;
-// final byte[] holeLine = new byte[line.length + nextline.length];
-// System.arraycopy(line, 0, holeLine, 0, line.length);
-// System.arraycopy(nextline, 0, holeLine, line.length, nextline.length);
-// p = indexOf(q, holeLine, quotec);
-// if(p > 0)
-// throw new IOException("missing quote in filename tag: '" + new String(line) + "'");
-// }
-// filename = new byte[q - p];
-// java.lang.System.arraycopy(line, p, filename, 0, q - p);
-// } else filename = null;
-// // we have what we need. more information lines may follow, but we omit parsing them
-// // we just skip until an empty line is reached
-// while (pos < buffer.length) { // line skiping
-// line = readLine(pos, buffer); pos = nextPos;
-// if ((line == null) || (line.length == 0)) break;
-// }
-// // depending on the filename tag exsistence, read now either a value for the name
-// // or a complete uploaded file
-// // to know the exact length of the value, we must identify the next boundary
-// p = indexOf(pos, buffer, boundary);
-//
-// // if we can't find another boundary, then this is an error in the input
-// if (p < 0) {
-// log.logSevere("ERROR in PUT body: no ending boundary. probably missing values");
-// break;
-// }
-//
-// // we don't know if the value is terminated by LF, CR or CRLF
-// // (it's suppose to be CRLF, but we want to be lazy about wrong terminations)
-// if (buffer[p - 2] == serverCore.CR) // ERROR: IndexOutOfBounds: -2
-// /* CRLF */ q = p - 2;
-// else
-// /* CR or LF only */ q = p - 1;
-// // the above line is wrong if we uploaded a file that has a CR as it's last byte
-// // and the client's line termination symbol is only a CR or LF (which would be incorrect)
-// // the value is between 'pos' and 'q', while the next marker is 'p'
-// line = new byte[q - pos];
-// java.lang.System.arraycopy(buffer, pos, line, 0, q - pos);
-// // in the 'line' variable we have now either a normal value or an uploadef file
-// if (filename == null) {
-// args.put(new String(name, "UTF-8"), new String(line, "UTF-8"));
-// } else {
-// // we store the file in a hashtable.
-// // we use the same key to address the file in the hashtable as we
-// // use to address the filename in the properties, but without leading '&'
-// args.put(new String(name, "UTF-8"), new String(filename, "UTF-8"));
-// files.put(new String(name, "UTF-8"), line);
-// }
-// argc++;
-// // finally, read the next boundary line
-// line = readLine(p, buffer);
-// pos = nextPos;
-// }
-// header.put("ARGC", Integer.toString(argc)); // store argument count
-// return files;
-// }
-
- /*
- ------------1090358578442
- Content-Disposition: form-data; name="youare"
-
- Ty2F86ekSWM5
- ------------1090358578442
- Content-Disposition: form-data; name="key"
-
- 6EkPPOl7
- ------------1090358578442
- Content-Disposition: form-data; name="iam"
-
- HnTvzwV7SCJR
- ------------1090358578442
- Content-Disposition: form-data; name="process"
-
- permission
- ------------1090358578442
-
- */
/**
* wraps the request into a org.apache.commons.fileupload.RequestContext
@@ -1092,9 +934,11 @@ public final class httpd implements serverHandler, Cloneable {
* @author danielr
* @since 07.08.2008
*/
- private static class yacyContextRequest implements RequestContext {
- private final httpHeader header;
- private final InputStream inStream;
+ private static class yacyContextRequest extends httpRequestHeader implements RequestContext {
+
+ private static final long serialVersionUID = -8936741958551376593L;
+
+ private final InputStream inStream;
/**
* creates a new yacyContextRequest
@@ -1102,42 +946,11 @@ public final class httpd implements serverHandler, Cloneable {
* @param header
* @param in
*/
- public yacyContextRequest(httpHeader header, InputStream in) {
- this.header = header;
+ public yacyContextRequest(Map<String, String> requestHeader, InputStream in) {
+ super(null, requestHeader);
this.inStream = in;
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.commons.fileupload.RequestContext#getCharacterEncoding()
- */
- //@Override
- public String getCharacterEncoding() {
- return header.getCharacterEncoding();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.commons.fileupload.RequestContext#getContentLength()
- */
- //@Override
- public int getContentLength() {
- return (int) header.contentLength();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.commons.fileupload.RequestContext#getContentType()
- */
- //@Override
- public String getContentType() {
- return header.get(httpHeader.CONTENT_TYPE);
- }
-
/*
* (non-Javadoc)
*
@@ -1254,27 +1067,27 @@ public final class httpd implements serverHandler, Cloneable {
final Object detailedErrorMsgFile,
final serverObjects detailedErrorMsgValues,
final Throwable stackTrace,
- httpHeader header
+ httpResponseHeader header
) throws IOException {
FileInputStream fis = null;
ByteArrayOutputStream o = null;
try {
// setting the proper http status message
- final String httpVersion = conProp.getProperty(httpHeader.CONNECTION_PROP_HTTP_VER,"HTTP/1.1");
+ final String httpVersion = conProp.getProperty(httpRequestHeader.CONNECTION_PROP_HTTP_VER,"HTTP/1.1");
if ((httpStatusText == null)||(httpStatusText.length()==0)) {
- if (httpVersion.equals("HTTP/1.0") && httpHeader.http1_0.containsKey(Integer.toString(httpStatusCode)))
- httpStatusText = httpHeader.http1_0.get(Integer.toString(httpStatusCode));
- else if (httpVersion.equals("HTTP/1.1") && httpHeader.http1_1.containsKey(Integer.toString(httpStatusCode)))
- httpStatusText = httpHeader.http1_1.get(Integer.toString(httpStatusCode));
+ if (httpVersion.equals("HTTP/1.0") && httpRequestHeader.http1_0.containsKey(Integer.toString(httpStatusCode)))
+ httpStatusText = httpRequestHeader.http1_0.get(Integer.toString(httpStatusCode));
+ else if (httpVersion.equals("HTTP/1.1") && httpRequestHeader.http1_1.containsKey(Integer.toString(httpStatusCode)))
+ httpStatusText = httpRequestHeader.http1_1.get(Integer.toString(httpStatusCode));
else httpStatusText = "Unknown";
}
// generating the desired request url
- String host = conProp.getProperty(httpHeader.CONNECTION_PROP_HOST);
- final String path = conProp.getProperty(httpHeader.CONNECTION_PROP_PATH,"/");
- final String args = conProp.getProperty(httpHeader.CONNECTION_PROP_ARGS);
- final String method = conProp.getProperty(httpHeader.CONNECTION_PROP_METHOD);
+ String host = conProp.getProperty(httpRequestHeader.CONNECTION_PROP_HOST);
+ final String path = conProp.getProperty(httpRequestHeader.CONNECTION_PROP_PATH,"/");
+ final String args = conProp.getProperty(httpRequestHeader.CONNECTION_PROP_ARGS);
+ final String method = conProp.getProperty(httpRequestHeader.CONNECTION_PROP_METHOD);
int port = 80;
final int pos = host.indexOf(":");
@@ -1285,7 +1098,7 @@ public final class httpd implements serverHandler, Cloneable {
String urlString;
try {
- urlString = (new yacyURL((method.equals(httpHeader.METHOD_CONNECT)?"https":"http"), host, port, (args == null) ? path : path + "?" + args)).toString();
+ urlString = (new yacyURL((method.equals(httpRequestHeader.METHOD_CONNECT)?"https":"http"), host, port, (args == null) ? path : path + "?" + args)).toString();
} catch (final MalformedURLException e) {
urlString = "invalid URL";
}
@@ -1296,7 +1109,7 @@ public final class httpd implements serverHandler, Cloneable {
// tp.put("host", serverCore.publicIP().getHostAddress());
// tp.put("port", switchboard.getConfig("port", "8080"));
- final String clientIP = conProp.getProperty(httpHeader.CONNECTION_PROP_CLIENTIP, "127.0.0.1");
+ final String clientIP = conProp.getProperty(httpRequestHeader.CONNECTION_PROP_CLIENTIP, "127.0.0.1");
// check if ip is local ip address
final InetAddress hostAddress = serverDomains.dnsResolve(clientIP);
@@ -1323,7 +1136,7 @@ public final class httpd implements serverHandler, Cloneable {
tp.put("peerName", (getAlternativeResolver() == null) ? "" : getAlternativeResolver().myName());
tp.put("errorMessageType", errorcase);
tp.put("httpStatus", Integer.toString(httpStatusCode) + " " + httpStatusText);
- tp.put("requestMethod", conProp.getProperty(httpHeader.CONNECTION_PROP_METHOD));
+ tp.put("requestMethod", conProp.getProperty(httpRequestHeader.CONNECTION_PROP_METHOD));
tp.put("requestURL", urlString);
switch (errorcase) {
@@ -1371,12 +1184,12 @@ public final class httpd implements serverHandler, Cloneable {
o.close(); o = null;
if(header == null)
- header = new httpHeader();
- header.put(httpHeader.CONNECTION_PROP_PROXY_RESPOND_STATUS, Integer.toString(httpStatusCode));
- header.put(httpHeader.DATE, systemDate);
- header.put(httpHeader.CONTENT_TYPE, "text/html");
- header.put(httpHeader.CONTENT_LENGTH, Integer.toString(result.length));
- header.put(httpHeader.PRAGMA, "no-cache");
+ header = new httpResponseHeader();
+ header.put(httpResponseHeader.CONNECTION_PROP_PROXY_RESPOND_STATUS, Integer.toString(httpStatusCode));
+ header.put(httpResponseHeader.DATE, systemDate);
+ header.put(httpResponseHeader.CONTENT_TYPE, "text/html");
+ header.put(httpResponseHeader.CONTENT_LENGTH, Integer.toString(result.length));
+ header.put(httpResponseHeader.PRAGMA, "no-cache");
sendRespondHeader(conProp,respond,httpVersion,httpStatusCode,httpStatusText,header);
if (! method.equals(httpHeader.METHOD_HEAD)) {
@@ -1411,7 +1224,7 @@ public final class httpd implements serverHandler, Cloneable {
final long contentLength,
final Date moddate,
final Date expires,
- final httpHeader headers,
+ final httpResponseHeader headers,
final String contentEnc,
final String transferEnc
) throws IOException {
@@ -1428,7 +1241,7 @@ public final class httpd implements serverHandler, Cloneable {
final long contentLength,
Date moddate,
final Date expires,
- httpHeader headers,
+ httpResponseHeader headers,
final String contentEnc,
final String transferEnc,
final boolean nocache
@@ -1451,17 +1264,17 @@ public final class httpd implements serverHandler, Cloneable {
}
}
- if(headers==null) headers = new httpHeader();
+ if(headers==null) headers = new httpResponseHeader();
final Date now = new Date(System.currentTimeMillis());
- headers.put(httpHeader.SERVER, "AnomicHTTPD (www.anomic.de)");
- headers.put(httpHeader.DATE, HttpClient.dateString(now));
+ headers.put(httpResponseHeader.SERVER, "AnomicHTTPD (www.anomic.de)");
+ headers.put(httpResponseHeader.DATE, HttpClient.dateString(now));
if (moddate.after(now)) moddate = now;
- headers.put(httpHeader.LAST_MODIFIED, HttpClient.dateString(moddate));
+ headers.put(httpResponseHeader.LAST_MODIFIED, HttpClient.dateString(moddate));
if (nocache) {
- if (httpVersion.toUpperCase().equals(httpHeader.HTTP_VERSION_1_1)) headers.put(httpHeader.CACHE_CONTROL, "no-cache");
- else headers.put(httpHeader.PRAGMA, "no-cache");
+ if (httpVersion.toUpperCase().equals(httpHeader.HTTP_VERSION_1_1)) headers.put(httpResponseHeader.CACHE_CONTROL, "no-cache");
+ else headers.put(httpResponseHeader.PRAGMA, "no-cache");
}
if (contentType == null)
@@ -1469,11 +1282,11 @@ public final class httpd implements serverHandler, Cloneable {
else if (contentType.startsWith("text/") && contentType.toLowerCase().indexOf("charset=")==-1)
contentType +="; charset=UTF-8";
headers.put(httpHeader.CONTENT_TYPE, contentType);
- if (contentLength > 0) headers.put(httpHeader.CONTENT_LENGTH, Long.toString(contentLength));
- //if (cookie != null) headers.put(httpHeader.SET_COOKIE, cookie);
- if (expires != null) headers.put(httpHeader.EXPIRES, HttpClient.dateString(expires));
- if (contentEnc != null) headers.put(httpHeader.CONTENT_ENCODING, contentEnc);
- if (transferEnc != null) headers.put(httpHeader.TRANSFER_ENCODING, transferEnc);
+ if (contentLength > 0) headers.put(httpResponseHeader.CONTENT_LENGTH, Long.toString(contentLength));
+ //if (cookie != null) headers.put(httpResponseHeader.SET_COOKIE, cookie);
+ if (expires != null) headers.put(httpResponseHeader.EXPIRES, HttpClient.dateString(expires));
+ if (contentEnc != null) headers.put(httpResponseHeader.CONTENT_ENCODING, contentEnc);
+ if (transferEnc != null) headers.put(httpResponseHeader.TRANSFER_ENCODING, transferEnc);
sendRespondHeader(conProp, respond, httpVersion, httpStatusCode, httpStatusText, headers);
}
@@ -1483,7 +1296,7 @@ public final class httpd implements serverHandler, Cloneable {
final OutputStream respond,
final String httpVersion,
final int httpStatusCode,
- final httpHeader header
+ final httpResponseHeader header
) throws IOException {
sendRespondHeader(conProp,respond,httpVersion,httpStatusCode,null,header);
}
@@ -1494,20 +1307,20 @@ public final class httpd implements serverHandler, Cloneable {
String httpVersion,
final int httpStatusCode,
String httpStatusText,
- httpHeader header
+ httpResponseHeader responseHeader
) throws IOException {
if (respond == null) throw new NullPointerException("The outputstream must not be null.");
if (conProp == null) throw new NullPointerException("The connection property structure must not be null.");
if (httpVersion == null) httpVersion = conProp.getProperty(httpHeader.CONNECTION_PROP_HTTP_VER,httpHeader.HTTP_VERSION_1_1);
- if (header == null) header = new httpHeader();
+ if (responseHeader == null) responseHeader = new httpResponseHeader();
try {
if ((httpStatusText == null)||(httpStatusText.length()==0)) {
- if (httpVersion.equals(httpHeader.HTTP_VERSION_1_0) && httpHeader.http1_0.containsKey(Integer.toString(httpStatusCode)))
- httpStatusText = httpHeader.http1_0.get(Integer.toString(httpStatusCode));
- else if (httpVersion.equals(httpHeader.HTTP_VERSION_1_1) && httpHeader.http1_1.containsKey(Integer.toString(httpStatusCode)))
- httpStatusText = httpHeader.http1_1.get(Integer.toString(httpStatusCode));
+ if (httpVersion.equals(httpResponseHeader.HTTP_VERSION_1_0) && httpHeader.http1_0.containsKey(Integer.toString(httpStatusCode)))
+ httpStatusText = httpResponseHeader.http1_0.get(Integer.toString(httpStatusCode));
+ else if (httpVersion.equals(httpResponseHeader.HTTP_VERSION_1_1) && httpHeader.http1_1.containsKey(Integer.toString(httpStatusCode)))
+ httpStatusText = httpResponseHeader.http1_1.get(Integer.toString(httpStatusCode));
else httpStatusText = "Unknown";
}
@@ -1521,25 +1334,25 @@ public final class httpd implements serverHandler, Cloneable {
.append(httpStatusText).append("\r\n");
// prepare header
- if (!header.containsKey(httpHeader.DATE))
- header.put(httpHeader.DATE, HttpClient.dateString(new Date()));
- if (!header.containsKey(httpHeader.CONTENT_TYPE))
- header.put(httpHeader.CONTENT_TYPE, "text/html; charset=UTF-8"); // fix this
- if (!header.containsKey(httpHeader.CONNECTION) && conProp.containsKey(httpHeader.CONNECTION_PROP_PERSISTENT))
- header.put(httpHeader.CONNECTION, conProp.getProperty(httpHeader.CONNECTION_PROP_PERSISTENT));
- if (!header.containsKey(httpHeader.PROXY_CONNECTION) && conProp.containsKey(httpHeader.CONNECTION_PROP_PERSISTENT))
- header.put(httpHeader.PROXY_CONNECTION, conProp.getProperty(httpHeader.CONNECTION_PROP_PERSISTENT));
+ if (!responseHeader.containsKey(httpHeader.DATE))
+ responseHeader.put(httpHeader.DATE, HttpClient.dateString(new Date()));
+ if (!responseHeader.containsKey(httpHeader.CONTENT_TYPE))
+ responseHeader.put(httpHeader.CONTENT_TYPE, "text/html; charset=UTF-8"); // fix this
+ if (!responseHeader.containsKey(httpRequestHeader.CONNECTION) && conProp.containsKey(httpHeader.CONNECTION_PROP_PERSISTENT))
+ responseHeader.put(httpRequestHeader.CONNECTION, conProp.getProperty(httpHeader.CONNECTION_PROP_PERSISTENT));
+ if (!responseHeader.containsKey(httpRequestHeader.PROXY_CONNECTION) && conProp.containsKey(httpHeader.CONNECTION_PROP_PERSISTENT))
+ responseHeader.put(httpRequestHeader.PROXY_CONNECTION, conProp.getProperty(httpHeader.CONNECTION_PROP_PERSISTENT));
if (conProp.containsKey(httpHeader.CONNECTION_PROP_PERSISTENT) &&
conProp.getProperty(httpHeader.CONNECTION_PROP_PERSISTENT).equals("keep-alive") &&
- !header.containsKey(httpHeader.TRANSFER_ENCODING) &&
- !header.containsKey(httpHeader.CONTENT_LENGTH))
- header.put(httpHeader.CONTENT_LENGTH, "0");
+ !responseHeader.containsKey(httpHeader.TRANSFER_ENCODING) &&
+ !responseHeader.containsKey(httpHeader.CONTENT_LENGTH))
+ responseHeader.put(httpHeader.CONTENT_LENGTH, "0");
// adding some yacy specific headers
- header.put(httpHeader.X_YACY_KEEP_ALIVE_REQUEST_COUNT,conProp.getProperty(httpHeader.CONNECTION_PROP_KEEP_ALIVE_COUNT));
- header.put(httpHeader.X_YACY_ORIGINAL_REQUEST_LINE,conProp.getProperty(httpHeader.CONNECTION_PROP_REQUESTLINE));
- header.put(httpHeader.X_YACY_PREVIOUS_REQUEST_LINE,conProp.getProperty(httpHeader.CONNECTION_PROP_PREV_REQUESTLINE));
+ responseHeader.put(httpResponseHeader.X_YACY_KEEP_ALIVE_REQUEST_COUNT,conProp.getProperty(httpRequestHeader.CONNECTION_PROP_KEEP_ALIVE_COUNT));
+ responseHeader.put(httpResponseHeader.X_YACY_ORIGINAL_REQUEST_LINE,conProp.getProperty(httpRequestHeader.CONNECTION_PROP_REQUESTLINE));
+ responseHeader.put(httpResponseHeader.X_YACY_PREVIOUS_REQUEST_LINE,conProp.getProperty(httpRequestHeader.CONNECTION_PROP_PREV_REQUESTLINE));
//read custom headers
/*
@@ -1548,11 +1361,11 @@ public final class httpd implements serverHandler, Cloneable {
httpHeader outgoingHeader=requestProperties.getOutgoingHeader();
if (outgoingHeader!=null)
{*/
- final Iterator<httpHeader.Entry> it = header.getCookies();
+ final Iterator<httpResponseHeader.Entry> it = responseHeader.getCookies();
while(it.hasNext()) {
//Append user properties to the main String
//TODO: Should we check for user properites. What if they intersect properties that are already in header?
- final httpHeader.Entry e = it.next();
+ final httpResponseHeader.Entry e = it.next();
headerStringBuffer.append(e.getKey()).append(": ").append(e.getValue()).append("\r\n");
}
@@ -1561,7 +1374,7 @@ public final class httpd implements serverHandler, Cloneable {
}*/
// write header
- final Iterator<String> i = header.keySet().iterator();
+ final Iterator<String> i = responseHeader.keySet().iterator();
String key;
char tag;
int count;
@@ -1570,9 +1383,9 @@ public final class httpd implements serverHandler, Cloneable {
key = i.next();
tag = key.charAt(0);
if ((tag != '*') && (tag != '#')) { // '#' in key is reserved for proxy attributes as artificial header values
- count = header.keyCount(key);
+ count = responseHeader.keyCount(key);
for (int j = 0; j < count; j++) {
- headerStringBuffer.append(key).append(": ").append((String) header.getSingle(key, j)).append("\r\n");
+ headerStringBuffer.append(key).append(": ").append((String) responseHeader.getSingle(key, j)).append("\r\n");
}
//System.out.println("#" + key + ": " + value);
}
@@ -1588,7 +1401,7 @@ public final class httpd implements serverHandler, Cloneable {
respond.flush();
}
- conProp.put(httpHeader.CONNECTION_PROP_PROXY_RESPOND_HEADER,header);
+ conProp.put(httpHeader.CONNECTION_PROP_PROXY_RESPOND_HEADER,responseHeader);
conProp.put(httpHeader.CONNECTION_PROP_PROXY_RESPOND_STATUS,Integer.toString(httpStatusCode));
} catch (final Exception e) {
// any interruption may be caused be network error or because the user has closed
diff --git a/source/de/anomic/http/httpdFileHandler.java b/source/de/anomic/http/httpdFileHandler.java
index 998bf4905..3df3cb626 100644
--- a/source/de/anomic/http/httpdFileHandler.java
+++ b/source/de/anomic/http/httpdFileHandler.java
@@ -74,7 +74,6 @@ import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
import java.util.logging.Level;
-import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
import de.anomic.htmlFilter.htmlFilterContentScraper;
@@ -222,8 +221,8 @@ public final class httpdFileHandler {
// out.flush();
// }
- private static final httpHeader getDefaultHeaders(final String path) {
- final httpHeader headers = new httpHeader();
+ private static final httpResponseHeader getDefaultHeaders(final String path) {
+ final httpResponseHeader headers = new httpResponseHeader();
String ext;
int pos;
if ((pos = path.lastIndexOf('.')) < 0) {
@@ -231,27 +230,27 @@ public final class httpdFileHandler {
} else {
ext = path.substring(pos + 1).toLowerCase();
}
- headers.put(httpHeader.SERVER, "AnomicHTTPD (www.anomic.de)");
- headers.put(httpHeader.DATE, HttpClient.dateString(new Date()));
+ headers.put(httpResponseHeader.SERVER, "AnomicHTTPD (www.anomic.de)");
+ headers.put(httpResponseHeader.DATE, HttpClient.dateString(new Date()));
if(!(plasmaParser.mediaExtContains(ext))){
- headers.put(httpHeader.PRAGMA, "no-cache");
+ headers.put(httpResponseHeader.PRAGMA, "no-cache");
}
return headers;
}
- public static void doGet(final Properties conProp, final httpHeader requestHeader, final OutputStream response) {
+ public static void doGet(final Properties conProp, final httpRequestHeader requestHeader, final OutputStream response) {
doResponse(conProp, requestHeader, response, null);
}
- public static void doHead(final Properties conProp, final httpHeader requestHeader, final OutputStream response) {
+ public static void doHead(final Properties conProp, final httpRequestHeader requestHeader, final OutputStream response) {
doResponse(conProp, requestHeader, response, null);
}
- public static void doPost(final Properties conProp, final httpHeader requestHeader, final OutputStream response, final InputStream body) {
+ public static void doPost(final Properties conProp, final httpRequestHeader requestHeader, final OutputStream response, final InputStream body) {
doResponse(conProp, requestHeader, response, body);
}
- public static void doResponse(final Properties conProp, final httpHeader requestHeader, final OutputStream out, final InputStream body) {
+ public static void doResponse(final Properties conProp, final httpRequestHeader requestHeader, final OutputStream out, final InputStream body) {
String path = null;
try {
@@ -283,7 +282,7 @@ public final class httpdFileHandler {
}
// check permission/granted access
- String authorization = requestHeader.get(httpHeader.AUTHORIZATION);
+ String authorization = requestHeader.get(httpRequestHeader.AUTHORIZATION);
if (authorization != null && authorization.length() == 0) authorization = null;
final String adminAccountBase64MD5 = switchboard.getConfig(httpd.ADMIN_ACCOUNT_B64MD5, "");
@@ -300,13 +299,13 @@ public final class httpdFileHandler {
// authentication required
if (authorization == null) {
// no authorization given in response. Ask for that
- final httpHeader headers = getDefaultHeaders(path);
- headers.put(httpHeader.WWW_AUTHENTICATE,"Basic realm=\"admin log-in\"");
+ final httpResponseHeader responseHeader = getDefaultHeaders(path);
+ responseHeader.put(httpRequestHeader.WWW_AUTHENTICATE,"Basic realm=\"admin log-in\"");
//httpd.sendRespondHeader(conProp,out,httpVersion,401,headers);
final servletProperties tp=new servletProperties();
tp.put("returnto", path);
- //TODO: separate errorpage Wrong Login / No Login
- httpd.sendRespondError(conProp, out, 5, 401, "Wrong Authentication", "", new File("proxymsg/authfail.inc"), tp, null, headers);
+ //TODO: separate error page Wrong Login / No Login
+ httpd.sendRespondError(conProp, out, 5, 401, "Wrong Authentication", "", new File("proxymsg/authfail.inc"), tp, null, responseHeader);
return;
} else if (
(httpd.staticAdminAuthenticated(authorization.trim().substring(6), switchboard) == 4) ||
@@ -322,8 +321,8 @@ public final class httpdFileHandler {
else
serverCore.bfHost.put(clientIP, Integer.valueOf(attempts.intValue() + 1));
- final httpHeader headers = getDefaultHeaders(path);
- headers.put(httpHeader.WWW_AUTHENTICATE,"Basic realm=\"admin log-in\"");
+ final httpResponseHeader headers = getDefaultHeaders(path);
+ headers.put(httpRequestHeader.WWW_AUTHENTICATE,"Basic realm=\"admin log-in\"");
httpd.sendRespondHeader(conProp,out,httpVersion,401,headers);
return;
}
@@ -337,27 +336,12 @@ public final class httpdFileHandler {
int length = 0;
//System.out.println("HEADER: " + requestHeader.toString()); // DEBUG
if (method.equals(httpHeader.METHOD_POST)) {
-
- GZIPInputStream gzipBody = null;
- /* "If the message does include a non-identity transfer-coding, the Content-Length MUST be ignored."
- * [RFC 2616 HTTP/1.1, section 4.4] TODO: full RFC compliance
- */
- if (requestHeader.gzip()) {
- length = -1;
- gzipBody = new GZIPInputStream(body);
- } else if (requestHeader.containsKey(httpHeader.CONTENT_LENGTH)) {
- length = Integer.parseInt(requestHeader.get(httpHeader.CONTENT_LENGTH));
- }
- // } else {
- // httpd.sendRespondError(conProp,out,4,403,null,"bad post values",null);
- // return;
- // }
-
+
// if its a POST, it can be either multipart or as args in the body
if ((requestHeader.containsKey(httpHeader.CONTENT_TYPE)) &&
(requestHeader.get(httpHeader.CONTENT_TYPE).toLowerCase().startsWith("multipart"))) {
// parse multipart
- final HashMap<String, byte[]> files = httpd.parseMultipart(requestHeader, args, (gzipBody!=null)?gzipBody:body, length);
+ final HashMap<String, byte[]> files = httpd.parseMultipart(requestHeader, args, body, length);
// integrate these files into the args
if (files != null) {
final Iterator<Map.Entry<String, byte[]>> fit = files.entrySet().iterator();
@@ -370,7 +354,7 @@ public final class httpdFileHandler {
argc = Integer.parseInt(requestHeader.get("ARGC"));
} else {
// parse args in body
- argc = httpd.parseArgs(args, (gzipBody!=null)?gzipBody:body, length);
+ argc = httpd.parseArgs(args, body, length);
}
} else {
// no args
@@ -488,7 +472,7 @@ public final class httpdFileHandler {
aBuffer.append(" </ul>\n</body>\n</html>\n");
// write the list to the client
- httpd.sendRespondHeader(conProp, out, httpVersion, 200, null, "text/html", aBuffer.length(), new Date(dir.lastModified()), null, new httpHeader(), null, null, true);
+ httpd.sendRespondHeader(conProp, out, httpVersion, 200, null, "text/html", aBuffer.length(), new Date(dir.lastModified()), null, new httpResponseHeader(), null, null, true);
if (!method.equals(httpHeader.METHOD_HEAD)) {
out.write(aBuffer.toString().getBytes());
}
@@ -633,15 +617,15 @@ public final class httpdFileHandler {
serverCore.bfHost.put(clientIP, Integer.valueOf(attempts.intValue() + 1));
}
// send authentication request to browser
- final httpHeader headers = getDefaultHeaders(path);
- headers.put(httpHeader.WWW_AUTHENTICATE,"Basic realm=\"" + tp.get(servletProperties.ACTION_AUTHENTICATE, "") + "\"");
+ final httpResponseHeader headers = getDefaultHeaders(path);
+ headers.put(httpRequestHeader.WWW_AUTHENTICATE,"Basic realm=\"" + tp.get(servletProperties.ACTION_AUTHENTICATE, "") + "\"");
httpd.sendRespondHeader(conProp,out,httpVersion,401,headers);
return;
} else if (tp.containsKey(servletProperties.ACTION_LOCATION)) {
String location = tp.get(servletProperties.ACTION_LOCATION, "");
if (location.length() == 0) location = path;
- final httpHeader headers = getDefaultHeaders(path);
+ final httpResponseHeader headers = getDefaultHeaders(path);
headers.setCookieVector(tp.getOutgoingHeader().getCookieVector()); //put the cookies into the new header TODO: can we put all headerlines, without trouble?
headers.put(httpHeader.LOCATION,location);
httpd.sendRespondHeader(conProp,out,httpVersion,302,headers);
@@ -767,7 +751,7 @@ public final class httpdFileHandler {
int statusCode = 200;
int rangeStartOffset = 0;
- httpHeader header = new httpHeader();
+ httpResponseHeader header = new httpResponseHeader();
// adding the accept ranges header
header.put(httpHeader.ACCEPT_RANGES, "bytes");
@@ -804,7 +788,7 @@ public final class httpdFileHandler {
if ((ranges.length == 1)&&(ranges[0].endsWith("-"))) {
rangeStartOffset = Integer.valueOf(ranges[0].substring(0,ranges[0].length()-1)).intValue();
statusCode = 206;
- if (header == null) header = new httpHeader();
+ if (header == null) header = new httpResponseHeader();
header.put(httpHeader.CONTENT_RANGE, "bytes " + rangeStartOffset + "-" + (targetFile.length()-1) + "/" + targetFile.length());
}
}
@@ -848,7 +832,7 @@ public final class httpdFileHandler {
try {newOut.flush();}catch (final Exception e) {}
// wait a little time until everything closes so that clients can read from the streams/sockets
- if ((contentLength >= 0) && ((String)requestHeader.get(httpHeader.CONNECTION, "close")).indexOf("keep-alive") == -1) {
+ if ((contentLength >= 0) && ((String)requestHeader.get(httpRequestHeader.CONNECTION, "close")).indexOf("keep-alive") == -1) {
// in case that the client knows the size in advance (contentLength present) the waiting will have no effect on the interface performance
// but if the client waits on a connection interruption this will slow down.
try {Thread.sleep(2000);} catch (final InterruptedException e) {} // FIXME: is this necessary?
@@ -985,7 +969,7 @@ public final class httpdFileHandler {
final Class<?> c = provider.loadClass(classFile);
final Class<?>[] params = new Class[] {
- httpHeader.class,
+ httpRequestHeader.class,
serverObjects.class,
serverSwitch.class };
m = c.getMethod("respond", params);
@@ -1005,7 +989,7 @@ public final class httpdFileHandler {
return m;
}
- public static final Object invokeServlet(final File targetClass, final httpHeader request, final serverObjects args) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
+ public static final Object invokeServlet(final File targetClass, final httpRequestHeader request, final serverObjects args) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
Object result;
if (safeServletsMode) synchronized (switchboard) {
result = rewriteMethod(targetClass).invoke(null, new Object[] {request, args, switchboard});
diff --git a/source/de/anomic/http/httpdProxyCacheEntry.java b/source/de/anomic/http/httpdProxyCacheEntry.java
index ddbcd1dea..190029d6f 100755
--- a/source/de/anomic/http/httpdProxyCacheEntry.java
+++ b/source/de/anomic/http/httpdProxyCacheEntry.java
@@ -30,12 +30,13 @@ import java.io.File;
import java.util.Date;
import de.anomic.crawler.CrawlProfile;
+import de.anomic.index.indexDocumentMetadata;
import de.anomic.plasma.plasmaHTCache;
-import de.anomic.plasma.cache.IResourceInfo;
+import de.anomic.server.serverDate;
import de.anomic.server.serverSystem;
import de.anomic.yacy.yacyURL;
-public class httpdProxyCacheEntry {
+public class httpdProxyCacheEntry implements indexDocumentMetadata {
// doctypes:
public static final char DT_PDFPS = 'p';
@@ -57,16 +58,11 @@ public class httpdProxyCacheEntry {
private byte[] cacheArray; // or the cache as byte-array
private final yacyURL url;
private final String name; // the name of the link, read as anchor from an <a>-tag
- private final Date lastModified;
- private char doctype;
private final String language;
private final CrawlProfile.entry profile;
private final String initiator;
-
- /**
- * protocol specific information about the resource
- */
- private final IResourceInfo resInfo;
+ private httpRequestHeader requestHeader;
+ private httpResponseHeader responseHeader;
// doctype calculation
public static char docType(final yacyURL url) {
@@ -139,15 +135,21 @@ public class httpdProxyCacheEntry {
return doctype;
}
- public httpdProxyCacheEntry(final int depth,
- final yacyURL url, final String name, final String responseStatus,
- final IResourceInfo resourceInfo, final String initiator,
+ public httpdProxyCacheEntry(
+ final int depth,
+ final yacyURL url,
+ final String name,
+ final String responseStatus,
+ final httpRequestHeader requestHeader,
+ final httpResponseHeader responseHeader,
+ final String initiator,
final CrawlProfile.entry profile) {
- if (resourceInfo == null) {
- System.out.println("Content information object is null. " + url);
+ if (responseHeader == null) {
+ System.out.println("Response header information is null. " + url);
System.exit(0);
}
- this.resInfo = resourceInfo;
+ this.requestHeader = requestHeader;
+ this.responseHeader = responseHeader;
this.url = url;
this.name = name;
this.cacheFile = plasmaHTCache.getCachePath(this.url);
@@ -157,14 +159,6 @@ public class httpdProxyCacheEntry {
this.responseStatus = responseStatus;
this.profile = profile;
this.initiator = (initiator == null) ? null : ((initiator.length() == 0) ? null : initiator);
-
- // getting the last modified date
- this.lastModified = resourceInfo.getModificationDate();
-
- // getting the doctype
- this.doctype = docType(resourceInfo.getMimeType());
- if (this.doctype == DT_UNKNOWN)
- this.doctype = docType(url);
this.language = yacyURL.language(url);
// to be defined later:
@@ -180,15 +174,29 @@ public class httpdProxyCacheEntry {
public yacyURL url() {
return this.url;
}
+
+ public char docType() {
+ char doctype = docType(getMimeType());
+ if (doctype == DT_UNKNOWN) doctype = docType(url);
+ return doctype;
+ }
public String urlHash() {
return this.url.hash();
}
public Date lastModified() {
- return this.lastModified;
+ Date docDate = null;
+
+ if (responseHeader != null) {
+ docDate = responseHeader.lastModified();
+ if (docDate == null) docDate = responseHeader.date();
+ }
+ if (docDate == null) docDate = new Date(serverDate.correctedUTCTime());
+
+ return docDate;
}
-
+
public String language() {
return this.language;
}
@@ -215,10 +223,6 @@ public class httpdProxyCacheEntry {
return this.depth;
}
- public yacyURL referrerURL() {
- return (this.resInfo == null) ? null : this.resInfo.getRefererUrl();
- }
-
public File cacheFile() {
return this.cacheFile;
}
@@ -231,27 +235,6 @@ public class httpdProxyCacheEntry {
return this.cacheArray;
}
- public IResourceInfo getDocumentInfo() {
- return this.resInfo;
- }
-
- public String getMimeType() {
- return (this.resInfo == null) ? null : this.resInfo.getMimeType();
- }
-
- public Date ifModifiedSince() {
- return (this.resInfo == null) ? null : this.resInfo.ifModifiedSince();
- }
-
- public boolean requestWithCookie() {
- return (this.resInfo == null) ? false : this.resInfo.requestWithCookie();
- }
-
- public boolean requestProhibitsIndexing() {
- return (this.resInfo == null) ? false : this.resInfo.requestProhibitsIndexing();
- }
-
-
// the following three methods for cache read/write granting shall be as loose
// as possible but also as strict as necessary to enable caching of most items
@@ -269,8 +252,7 @@ public class httpdProxyCacheEntry {
// if the storage was requested by prefetching, the request map is null
// check status code
- if ((this.resInfo != null)
- && (!this.resInfo.validResponseStatus(this.responseStatus))) {
+ if (!validResponseStatus()) {
return "bad_status_" + this.responseStatus.substring(0, 3);
}
@@ -299,14 +281,70 @@ public class httpdProxyCacheEntry {
if (this.url.isCGI()) {
return "dynamic_cgi";
}
-
- if (this.resInfo != null) {
- return this.resInfo.shallStoreCacheForProxy();
+
+ if (requestHeader != null) {
+ // -authorization cases in request
+ // authorization makes pages very individual, and therefore we cannot use the
+ // content in the cache
+ if (requestHeader.containsKey(httpRequestHeader.AUTHORIZATION)) { return "personalized"; }
+ // -ranges in request and response
+ // we do not cache partial content
+ if (requestHeader.containsKey(httpHeader.RANGE)) { return "partial"; }
+ }
+
+ if (responseHeader != null) {
+ // -ranges in request and response
+ // we do not cache partial content
+ if (responseHeader.containsKey(httpHeader.CONTENT_RANGE)) { return "partial"; }
+
+ // -if-modified-since in request
+ // we do not care about if-modified-since, because this case only occurres if the
+ // cache file does not exist, and we need as much info as possible for the indexing
+
+ // -cookies in request
+ // we do not care about cookies, because that would prevent loading more pages
+ // from one domain once a request resulted in a client-side stored cookie
+
+ // -set-cookie in response
+ // we do not care about cookies in responses, because that info comes along
+ // any/many pages from a server and does not express the validity of the page
+ // in modes of life-time/expiration or individuality
+
+ // -pragma in response
+ // if we have a pragma non-cache, we don't cache. usually if this is wanted from
+ // the server, it makes sense
+ String cacheControl = responseHeader.get(httpResponseHeader.PRAGMA);
+ if (cacheControl != null && cacheControl.trim().toUpperCase().equals("NO-CACHE")) { return "controlled_no_cache"; }
+
+ // -expires in response
+ // we do not care about expires, because at the time this is called the data is
+ // obvious valid and that header info is used in the indexing later on
+
+ // -cache-control in response
+ // the cache-control has many value options.
+ cacheControl = responseHeader.get(httpResponseHeader.CACHE_CONTROL);
+ if (cacheControl != null) {
+ cacheControl = cacheControl.trim().toUpperCase();
+ if (cacheControl.startsWith("MAX-AGE=")) {
+ // we need also the load date
+ final Date date = responseHeader.date();
+ if (date == null) return "stale_no_date_given_in_response";
+ try {
+ final long ttl = 1000 * Long.parseLong(cacheControl.substring(8)); // milliseconds to live
+ if (serverDate.correctedUTCTime() - date.getTime() > ttl) {
+ //System.out.println("***not indexed because cache-control");
+ return "stale_expired";
+ }
+ } catch (final Exception e) {
+ return "stale_error_" + e.getMessage() + ")";
+ }
+ }
+ }
}
-
return null;
}
+
/**
* decide upon header information if a specific file should be taken from
* the cache or not
@@ -325,11 +363,170 @@ public class httpdProxyCacheEntry {
return false;
}
- if (this.resInfo != null) {
- return this.resInfo.shallUseCacheForProxy();
+ String cacheControl;
+ if (requestHeader != null) {
+ // -authorization cases in request
+ if (requestHeader.containsKey(httpRequestHeader.AUTHORIZATION)) { return false; }
+
+ // -ranges in request
+ // we do not cache partial content
+ if (requestHeader.containsKey(httpHeader.RANGE)) { return false; }
+
+ // if the client requests a un-cached copy of the resource ...
+ cacheControl = requestHeader.get(httpResponseHeader.PRAGMA);
+ if (cacheControl != null && cacheControl.trim().toUpperCase().equals("NO-CACHE")) { return false; }
+
+ cacheControl = requestHeader.get(httpResponseHeader.CACHE_CONTROL);
+ if (cacheControl != null) {
+ cacheControl = cacheControl.trim().toUpperCase();
+ if (cacheControl.startsWith("NO-CACHE") || cacheControl.startsWith("MAX-AGE=0")) { return false; }
+ }
+
+ // -if-modified-since in request
+ // The entity has to be transferred only if it has
+ // been modified since the date given by the If-Modified-Since header.
+ if (requestHeader.containsKey(httpRequestHeader.IF_MODIFIED_SINCE)) {
+ // checking this makes only sense if the cached response contains
+ // a Last-Modified field. If the field does not exist, we go the safe way
+ if (!responseHeader.containsKey(httpResponseHeader.LAST_MODIFIED)) { return false; }
+ // parse date
+ Date d1, d2;
+ d2 = responseHeader.lastModified(); if (d2 == null) { d2 = new Date(serverDate.correctedUTCTime()); }
+ d1 = requestHeader.ifModifiedSince(); if (d1 == null) { d1 = new Date(serverDate.correctedUTCTime()); }
+ // finally, we shall treat the cache as stale if the modification time is after the if-.. time
+ if (d2.after(d1)) { return false; }
+ }
+
+ final String mimeType = getMimeType();
+ if (!plasmaHTCache.isPicture(mimeType)) {
+ // -cookies in request
+ // unfortunately, we should reload in case of a cookie
+ // but we think that pictures can still be considered as fresh
+ // -set-cookie in cached response
+ // this is a similar case as for COOKIE.
+ if (requestHeader.containsKey(httpRequestHeader.COOKIE) ||
+ responseHeader.containsKey(httpResponseHeader.SET_COOKIE) ||
+ responseHeader.containsKey(httpResponseHeader.SET_COOKIE2)) {
+ return false; // too strong
+ }
+ }
}
+ if (responseHeader != null) {
+ // -pragma in cached response
+ // logically, we would not need to care about no-cache pragmas in cached response headers,
+ // because they cannot exist since they are not written to the cache.
+ // So this IF should always fail..
+ cacheControl = responseHeader.get(httpResponseHeader.PRAGMA);
+ if (cacheControl != null && cacheControl.trim().toUpperCase().equals("NO-CACHE")) { return false; }
+
+ // see for documentation also:
+ // http://www.web-caching.com/cacheability.html
+ // http://vancouver-webpages.com/CacheNow/
+
+ // look for freshnes information
+ // if we don't have any freshnes indication, we treat the file as stale.
+ // no handle for freshness control:
+
+ // -expires in cached response
+ // the expires value gives us a very easy hint when the cache is stale
+ final Date expires = responseHeader.expires();
+ if (expires != null) {
+ // System.out.println("EXPIRES-TEST: expires=" + expires + ", NOW=" + serverDate.correctedGMTDate() + ", url=" + url);
+ if (expires.before(new Date(serverDate.correctedUTCTime()))) { return false; }
+ }
+ final Date lastModified = responseHeader.lastModified();
+ cacheControl = responseHeader.get(httpResponseHeader.CACHE_CONTROL);
+ if (cacheControl == null && lastModified == null && expires == null) { return false; }
+
+ // -lastModified in cached response
+ // we can apply a TTL (Time To Live) heuristic here. We call the time delta between the last read
+ // of the file and the last modified date as the age of the file. If we consider the file as
+ // middel-aged then, the maximum TTL would be cache-creation plus age.
+ // This would be a TTL factor of 100% we want no more than 10% TTL, so that a 10 month old cache
+ // file may only be treated as fresh for one more month, not more.
+ Date date = responseHeader.date();
+ if (lastModified != null) {
+ if (date == null) { date = new Date(serverDate.correctedUTCTime()); }
+ final long age = date.getTime() - lastModified.getTime();
+ if (age < 0) { return false; }
+ // TTL (Time-To-Live) is age/10 = (d2.getTime() - d1.getTime()) / 10
+ // the actual living-time is serverDate.correctedGMTDate().getTime() - d2.getTime()
+ // therefore the cache is stale, if serverDate.correctedGMTDate().getTime() - d2.getTime() > age/10
+ if (serverDate.correctedUTCTime() - date.getTime() > age / 10) { return false; }
+ }
+
+ // -cache-control in cached response
+ // the cache-control has many value options.
+ if (cacheControl != null) {
+ cacheControl = cacheControl.trim().toUpperCase();
+ if (cacheControl.startsWith("PRIVATE") ||
+ cacheControl.startsWith("NO-CACHE") ||
+ cacheControl.startsWith("NO-STORE")) {
+ // easy case
+ return false;
+ // } else if (cacheControl.startsWith("PUBLIC")) {
+ // // ok, do nothing
+ } else if (cacheControl.startsWith("MAX-AGE=")) {
+ // we need also the load date
+ if (date == null) { return false; }
+ try {
+ final long ttl = 1000 * Long.parseLong(cacheControl.substring(8)); // milliseconds to live
+ if (serverDate.correctedUTCTime() - date.getTime() > ttl) {
+ return false;
+ }
+ } catch (final Exception e) {
+ return false;
+ }
+ }
+ }
+ }
+
return true;
}
+
+ public String getMimeType() {
+ if (responseHeader == null) return null;
+
+ String mimeType = responseHeader.mime();
+ mimeType = mimeType.trim().toLowerCase();
+
+ final int pos = mimeType.indexOf(';');
+ return ((pos < 0) ? mimeType : mimeType.substring(0, pos));
+ }
+
+ public String getCharacterEncoding() {
+ if (responseHeader == null) return null;
+ return responseHeader.getCharacterEncoding();
+ }
+
+ public yacyURL referrerURL() {
+ if (requestHeader == null) return null;
+ try {
+ return new yacyURL((String) requestHeader.get(httpRequestHeader.REFERER, ""), null);
+ } catch (final Exception e) {
+ return null;
+ }
+ }
+
+ public boolean validResponseStatus() {
+ return (responseStatus == null) ? false : responseStatus.startsWith("200") || responseStatus.startsWith("203");
+ }
+
+ public Date ifModifiedSince() {
+ return (requestHeader == null) ? null : requestHeader.ifModifiedSince();
+ }
+
+ public boolean requestWithCookie() {
+ return (requestHeader == null) ? false : requestHeader.containsKey(httpRequestHeader.COOKIE);
+ }
+
+ public boolean requestProhibitsIndexing() {
+ return (requestHeader == null)
+ ? false
+ : requestHeader.containsKey(httpHeader.X_YACY_INDEX_CONTROL) &&
+ (requestHeader.get(httpHeader.X_YACY_INDEX_CONTROL)).toUpperCase().equals("NO-INDEX");
+ }
+
}
diff --git a/source/de/anomic/http/httpdProxyHandler.java b/source/de/anomic/http/httpdProxyHandler.java
index 357e12503..efb63dce3 100644
--- a/source/de/anomic/http/httpdProxyHandler.java
+++ b/source/de/anomic/http/httpdProxyHandler.java
@@ -81,13 +81,12 @@ import de.anomic.crawler.HTTPLoader;
import de.anomic.htmlFilter.htmlFilterContentTransformer;
import de.anomic.htmlFilter.htmlFilterTransformer;
import de.anomic.htmlFilter.htmlFilterWriter;
+import de.anomic.index.indexDocumentMetadata;
import de.anomic.index.indexReferenceBlacklist;
import de.anomic.plasma.plasmaHTCache;
import de.anomic.plasma.plasmaParser;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.plasma.plasmaSwitchboardConstants;
-import de.anomic.plasma.cache.IResourceInfo;
-import de.anomic.plasma.cache.http.ResourceInfo;
import de.anomic.server.serverCore;
import de.anomic.server.serverDomains;
import de.anomic.server.serverFileUtils;
@@ -226,7 +225,7 @@ public final class httpdProxyHandler {
private static final StringBuffer userAgentStr = new StringBuffer();
- public static void handleOutgoingCookies(final httpHeader requestHeader, final String targethost, final String clienthost) {
+ public static void handleOutgoingCookies(final httpRequestHeader requestHeader, final String targethost, final String clienthost) {
/*
The syntax for the header is:
@@ -240,8 +239,8 @@ public final class httpdProxyHandler {
domain = "$Domain" "=" value
*/
if (switchboard.getConfigBool("proxy.monitorCookies", false)) {
- if (requestHeader.containsKey(httpHeader.COOKIE)) {
- final Object[] entry = new Object[]{new Date(), clienthost, requestHeader.getMultiple(httpHeader.COOKIE)};
+ if (requestHeader.containsKey(httpRequestHeader.COOKIE)) {
+ final Object[] entry = new Object[]{new Date(), clienthost, requestHeader.getMultiple(httpRequestHeader.COOKIE)};
synchronized(switchboard.outgoingCookies) {
switchboard.outgoingCookies.put(targethost, entry);
}
@@ -249,7 +248,7 @@ public final class httpdProxyHandler {
}
}
- public static void handleIncomingCookies(final httpHeader respondHeader, final String serverhost, final String targetclient) {
+ public static void handleIncomingCookies(final httpResponseHeader respondHeader, final String serverhost, final String targetclient) {
/*
The syntax for the Set-Cookie response header is
@@ -266,8 +265,8 @@ public final class httpdProxyHandler {
| "Version" "=" 1*DIGIT
*/
if (switchboard.getConfigBool("proxy.monitorCookies", false)) {
- if (respondHeader.containsKey(httpHeader.SET_COOKIE)) {
- final Object[] entry = new Object[]{new Date(), targetclient, respondHeader.getMultiple(httpHeader.SET_COOKIE)};
+ if (respondHeader.containsKey(httpResponseHeader.SET_COOKIE)) {
+ final Object[] entry = new Object[]{new Date(), targetclient, respondHeader.getMultiple(httpResponseHeader.SET_COOKIE)};
synchronized(switchboard.incomingCookies) {
switchboard.incomingCookies.put(serverhost, entry);
}
@@ -281,7 +280,7 @@ public final class httpdProxyHandler {
* @param respond the OutputStream to the client
* @see de.anomic.http.httpdHandler#doGet(java.util.Properties, de.anomic.http.httpHeader, java.io.OutputStream)
*/
- public static void doGet(final Properties conProp, final httpHeader requestHeader, final OutputStream respond) {
+ public static void doGet(final Properties conProp, final httpRequestHeader requestHeader, final OutputStream respond) {
httpdByteCountOutputStream countedRespond = null;
try {
final int reqID = requestHeader.hashCode();
@@ -367,15 +366,7 @@ public final class httpdProxyHandler {
// decide whether to use a cache entry or connect to the network
final File cacheFile = plasmaHTCache.getCachePath(url);
- httpHeader cachedResponseHeader = null;
- final ResourceInfo cachedResInfo = (ResourceInfo) plasmaHTCache.loadResourceInfo(url);
- if (cachedResInfo != null) {
- // set the new request header (needed by function shallUseCacheForProxy)
- cachedResInfo.setRequestHeader(requestHeader);
-
- // get the cached response header
- cachedResponseHeader = cachedResInfo.getResponseHeader();
- }
+ httpResponseHeader cachedResponseHeader = plasmaHTCache.loadResponseHeader(url);
final boolean cacheExists = cacheFile.isFile() && (cachedResponseHeader != null);
// why are files unzipped upon arrival? why not zip all files in cache?
@@ -400,18 +391,20 @@ public final class httpdProxyHandler {
// 4. cache stale - refill - superfluous
// in two of these cases we trigger a scheduler to handle newly arrived files:
// case 1 and case 3
- final httpdProxyCacheEntry cacheEntry = (cachedResponseHeader == null) ? null :
- plasmaHTCache.newEntry(
+ final indexDocumentMetadata cacheEntry = (cachedResponseHeader == null) ? null :
+ new httpdProxyCacheEntry(
0, // crawling depth
url, // url
"", // name of the url is unknown
//requestHeader, // request headers
"200 OK", // request status
- //cachedResponseHeader, // response headers
- cachedResInfo,
+ requestHeader,
+ cachedResponseHeader,
null, // initiator
switchboard.webIndex.defaultProxyProfile // profile
);
+ if (cacheEntry != null) plasmaHTCache.storeMetadata(cachedResponseHeader, cacheEntry);
+
if (yacyCore.getOnlineMode() == 0) {
if (cacheExists) {
theLogger.logFinest(reqID +" fulfill request from cache");
@@ -453,7 +446,7 @@ public final class httpdProxyHandler {
}
}
- private static void fulfillRequestFromWeb(final Properties conProp, final yacyURL url,final String ext, final httpHeader requestHeader, final httpHeader cachedResponseHeader, final File cacheFile, final OutputStream respond) {
+ private static void fulfillRequestFromWeb(final Properties conProp, final yacyURL url,final String ext, final httpRequestHeader requestHeader, final httpResponseHeader cachedResponseHeader, final File cacheFile, final OutputStream respond) {
final GZIPOutputStream gzippedOut = null;
Writer hfos = null;
@@ -499,9 +492,9 @@ public final class httpdProxyHandler {
try {
res = client.GET(getUrl);
theLogger.logFinest(reqID +" response status: "+ res.getStatusLine());
- conProp.put(httpHeader.CONNECTION_PROP_CLIENT_REQUEST_HEADER,requestHeader);
+ conProp.put(httpHeader.CONNECTION_PROP_CLIENT_REQUEST_HEADER, requestHeader);
- final httpHeader responseHeader = res.getResponseHeader();
+ final httpResponseHeader responseHeader = res.getResponseHeader();
// determine if it's an internal error of the httpc
if (responseHeader.size() == 0) {
throw new Exception(res.getStatusLine());
@@ -520,23 +513,22 @@ public final class httpdProxyHandler {
if ((cacheFile.isFile()) && (cachedResponseHeader != null)) {
// delete the cache
sizeBeforeDelete = cacheFile.length();
- plasmaHTCache.deleteURLfromCache(url);
+ plasmaHTCache.deleteURLfromCache(url, false);
conProp.setProperty(httpHeader.CONNECTION_PROP_PROXY_RESPOND_CODE,"TCP_REFRESH_MISS");
}
// reserver cache entry
- final IResourceInfo resInfo = new ResourceInfo(url,requestHeader,responseHeader);
- final httpdProxyCacheEntry cacheEntry = plasmaHTCache.newEntry(
+ final indexDocumentMetadata cacheEntry = new httpdProxyCacheEntry(
0,
url,
"",
- //requestHeader,
- res.getStatusLine(),
- //res.responseHeader,
- resInfo,
+ res.getStatusLine(),
+ requestHeader,
+ responseHeader,
null,
switchboard.webIndex.defaultProxyProfile
);
+ plasmaHTCache.storeMetadata(responseHeader, cacheEntry);
// handle file types and make (possibly transforming) output stream
final OutputStream outStream = (gzippedOut != null) ? gzippedOut : ((chunkedOut != null)? chunkedOut : respond);
@@ -547,12 +539,12 @@ public final class httpdProxyHandler {
// make a transformer
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 = httpHeader.getCharSet(responseHeader);
+ final Charset charSet = responseHeader.getCharSet();
hfos = new htmlFilterWriter(outStream,charSet, null, transformer, (ext.length() == 0));
} else {
// simply pass through without parsing
theLogger.logFine(reqID +" create passthrough for URL " + url + ", extension '" + ext + "', mime-type '" + responseHeader.mime() + "'");
- hfos = new OutputStreamWriter(outStream, httpHeader.getCharSet(responseHeader));
+ hfos = new OutputStreamWriter(outStream, responseHeader.getCharSet());
}
// handle incoming cookies
@@ -562,7 +554,7 @@ public final class httpdProxyHandler {
// sending the respond header back to the client
if (chunkedOut != null) {
- responseHeader.put(httpHeader.TRANSFER_ENCODING, "chunked");
+ responseHeader.put(httpResponseHeader.TRANSFER_ENCODING, "chunked");
}
theLogger.logFinest(reqID +" sending response header: "+ responseHeader);
@@ -589,7 +581,7 @@ public final class httpdProxyHandler {
*/
((storeHTCache) || (isSupportedContent))
) {
- final long contentLength = responseHeader.contentLength();
+ final long contentLength = responseHeader.getContentLength();
// we write a new cache entry
if ((contentLength > 0) && (contentLength < 1048576)) // if the length is known and < 1 MB
{
@@ -699,8 +691,8 @@ public final class httpdProxyHandler {
final Properties conProp,
final yacyURL url,
final String ext,
- final httpHeader requestHeader,
- final httpHeader cachedResponseHeader,
+ final httpRequestHeader requestHeader,
+ final httpResponseHeader cachedResponseHeader,
final File cacheFile,
final OutputStream respond
) throws IOException {
@@ -730,14 +722,14 @@ public final class httpdProxyHandler {
// }
// check if we can send a 304 instead the complete content
- if (requestHeader.containsKey(httpHeader.IF_MODIFIED_SINCE)) {
+ if (requestHeader.containsKey(httpRequestHeader.IF_MODIFIED_SINCE)) {
// conditional request: freshness of cache for that condition was already
// checked within shallUseCache(). Now send only a 304 response
theLogger.logInfo("CACHE HIT/304 " + cacheFile.toString());
conProp.setProperty(httpHeader.CONNECTION_PROP_PROXY_RESPOND_CODE,"TCP_REFRESH_HIT");
// setting the content length header to 0
- cachedResponseHeader.put(httpHeader.CONTENT_LENGTH, Integer.toString(0));
+ cachedResponseHeader.put(httpResponseHeader.CONTENT_LENGTH, Integer.toString(0));
// send cached header with replaced date and added length
httpd.sendRespondHeader(conProp,respond,httpVer,304,cachedResponseHeader);
@@ -748,14 +740,14 @@ public final class httpdProxyHandler {
conProp.setProperty(httpHeader.CONNECTION_PROP_PROXY_RESPOND_CODE,"TCP_HIT");
// setting the content header to the proper length
- cachedResponseHeader.put(httpHeader.CONTENT_LENGTH, Long.toString(cacheFile.length()));
+ cachedResponseHeader.put(httpResponseHeader.CONTENT_LENGTH, Long.toString(cacheFile.length()));
// send cached header with replaced date and added length
httpd.sendRespondHeader(conProp,respond,httpVer,203,cachedResponseHeader);
//respondHeader(respond, "203 OK", cachedResponseHeader); // respond with 'non-authoritative'
// determine the content charset
- final Charset charSet = httpHeader.getCharSet(cachedResponseHeader);
+ final Charset charSet = cachedResponseHeader.getCharSet();
// make a transformer
final OutputStream outStream = (gzippedOut != null) ? gzippedOut : ((chunkedOut != null)? chunkedOut : respond);
@@ -799,7 +791,7 @@ public final class httpdProxyHandler {
try {
final InputStream data = res.getDataAsStream();
if (data == null) return;
- final Charset charSet = httpHeader.getCharSet(res.getResponseHeader());
+ final Charset charSet = res.getResponseHeader().getCharSet();
serverFileUtils.copyToWriter(new BufferedInputStream(data), hfos, charSet);
} finally {
res.closeStream();
@@ -811,14 +803,14 @@ public final class httpdProxyHandler {
try {
final InputStream data = res.getDataAsStream();
if (data == null) return;
- final Charset charSet = httpHeader.getCharSet(res.getResponseHeader());
+ final Charset charSet = res.getResponseHeader().getCharSet();
serverFileUtils.copyToWriters(new BufferedInputStream(data), hfos, new BufferedWriter(new OutputStreamWriter(byteStream, charSet)) , charSet);
} finally {
res.closeStream();
}
}
- public static void doHead(final Properties conProp, final httpHeader requestHeader, OutputStream respond) {
+ public static void doHead(final Properties conProp, final httpRequestHeader requestHeader, OutputStream respond) {
JakartaCommonsHttpResponse res = null;
yacyURL url = null;
@@ -894,7 +886,7 @@ public final class httpdProxyHandler {
theLogger.logFinest(reqID +" response status: "+ res.getStatusLine());
// determine if it's an internal error of the httpc
- final httpHeader responseHeader = res.getResponseHeader();
+ final httpResponseHeader responseHeader = res.getResponseHeader();
if (responseHeader.size() == 0) {
throw new Exception(res.getStatusLine());
}
@@ -916,7 +908,7 @@ public final class httpdProxyHandler {
}
}
- public static void doPost(final Properties conProp, final httpHeader requestHeader, final OutputStream respond, InputStream body) throws IOException {
+ public static void doPost(final Properties conProp, final httpRequestHeader requestHeader, final OutputStream respond, InputStream body) throws IOException {
assert conProp != null : "precondition violated: conProp != null";
assert requestHeader != null : "precondition violated: requestHeader != null";
assert body != null : "precondition violated: body != null";
@@ -984,7 +976,7 @@ public final class httpdProxyHandler {
// "if there is a body to the call, we would have a CONTENT-LENGTH tag in the requestHeader"
// it seems that it is a HTTP/1.1 connection which stays open (the inputStream) and endlessly waits for
// input so we have to end it to do the request
- final long requestLength = requestHeader.contentLength();
+ final long requestLength = requestHeader.getContentLength();
if(requestLength > -1) {
final byte[] bodyData;
if(requestLength == 0) {
@@ -1004,7 +996,7 @@ public final class httpdProxyHandler {
res = client.POST(getUrl, body);
theLogger.logFinest(reqID +" response status: "+ res.getStatusLine());
- final httpHeader responseHeader = res.getResponseHeader();
+ final httpResponseHeader responseHeader = res.getResponseHeader();
// determine if it's an internal error of the httpc
if (responseHeader.size() == 0) {
throw new Exception(res.getStatusLine());
@@ -1016,7 +1008,7 @@ public final class httpdProxyHandler {
// sending the respond header back to the client
if (chunked != null) {
- responseHeader.put(httpHeader.TRANSFER_ENCODING, "chunked");
+ responseHeader.put(httpResponseHeader.TRANSFER_ENCODING, "chunked");
}
// sending response headers
@@ -1092,7 +1084,7 @@ public final class httpdProxyHandler {
* @param requestHeader
* @param hostlow
*/
- private static void prepareRequestHeader(final Properties conProp, final httpHeader requestHeader, final String hostlow) {
+ private static void prepareRequestHeader(final Properties conProp, final httpRequestHeader requestHeader, final String hostlow) {
// set another userAgent, if not yellow-listed
if ((yellowList != null) && (!(yellowList.contains(domain(hostlow))))) {
// change the User-Agent
@@ -1124,7 +1116,7 @@ public final class httpdProxyHandler {
* @param connectHost may be 'host:port' or 'host:port/path'
* @return
*/
- private static JakartaCommonsHttpClient setupHttpClient(final httpHeader requestHeader, final String connectHost) {
+ private static JakartaCommonsHttpClient setupHttpClient(final httpRequestHeader requestHeader, final String connectHost) {
// setup HTTP-client
final JakartaCommonsHttpClient client = new JakartaCommonsHttpClient(timeout, requestHeader);
client.setFollowRedirects(false);
@@ -1154,12 +1146,13 @@ public final class httpdProxyHandler {
* @param respond
* @return
*/
- private static httpChunkedOutputStream setTransferEncoding(final Properties conProp, final httpHeader responseHeader,
+ private static httpChunkedOutputStream setTransferEncoding(
+ final Properties conProp, final httpResponseHeader responseHeader,
final int statusCode, final OutputStream respond) {
final String httpVer = conProp.getProperty(httpHeader.CONNECTION_PROP_HTTP_VER);
httpChunkedOutputStream chunkedOut = null;
// gzipped response is ungzipped an therefor the length is unknown
- if (responseHeader.gzip() || responseHeader.contentLength() < 0) {
+ if (responseHeader.gzip() || responseHeader.getContentLength() < 0) {
// according to http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
// a 204,304 message must not contain a message body.
// Therefore we need to set the content-length to 0.
@@ -1181,7 +1174,7 @@ public final class httpdProxyHandler {
* @param res
* @param responseHeader
*/
- private static void prepareResponseHeader(final httpHeader responseHeader, final String httpVer) {
+ private static void prepareResponseHeader(final httpResponseHeader responseHeader, final String httpVer) {
modifyProxyHeaders(responseHeader, httpVer);
correctContentEncoding(responseHeader);
@@ -1190,10 +1183,10 @@ public final class httpdProxyHandler {
/**
* @param responseHeader
*/
- private static void correctContentEncoding(final httpHeader responseHeader) {
+ private static void correctContentEncoding(final httpResponseHeader responseHeader) {
// TODO gzip again? set "correct" encoding?
if(responseHeader.gzip()) {
- responseHeader.remove(httpHeader.CONTENT_ENCODING);
+ responseHeader.remove(httpResponseHeader.CONTENT_ENCODING);
responseHeader.remove(httpHeader.CONTENT_LENGTH); // remove gziped length
}
}
@@ -1204,7 +1197,7 @@ public final class httpdProxyHandler {
* @param conProp
* @param requestHeader
*/
- private static void addXForwardedForHeader(final Properties conProp, final httpHeader requestHeader) {
+ private static void addXForwardedForHeader(final Properties conProp, final httpRequestHeader requestHeader) {
// setting the X-Forwarded-For Header
if (switchboard.getConfigBool("proxy.sendXForwardedForHeader", true)) {
requestHeader.put(httpHeader.X_FORWARDED_FOR, conProp.getProperty(httpHeader.CONNECTION_PROP_CLIENTIP));
@@ -1227,24 +1220,24 @@ public final class httpdProxyHandler {
- Trailers
*/
- headers.remove(httpHeader.CONNECTION);
- headers.remove(httpHeader.KEEP_ALIVE);
- headers.remove(httpHeader.UPGRADE);
- headers.remove(httpHeader.TE);
- headers.remove(httpHeader.PROXY_CONNECTION);
- headers.remove(httpHeader.PROXY_AUTHENTICATE);
- headers.remove(httpHeader.PROXY_AUTHORIZATION);
+ headers.remove(httpRequestHeader.CONNECTION);
+ headers.remove(httpRequestHeader.KEEP_ALIVE);
+ headers.remove(httpRequestHeader.UPGRADE);
+ headers.remove(httpRequestHeader.TE);
+ headers.remove(httpRequestHeader.PROXY_CONNECTION);
+ headers.remove(httpRequestHeader.PROXY_AUTHENTICATE);
+ headers.remove(httpRequestHeader.PROXY_AUTHORIZATION);
// special headers inserted by squid
- headers.remove(httpHeader.X_CACHE);
- headers.remove(httpHeader.X_CACHE_LOOKUP);
+ headers.remove(httpRequestHeader.X_CACHE);
+ headers.remove(httpRequestHeader.X_CACHE_LOOKUP);
// remove transfer encoding header
- headers.remove(httpHeader.TRANSFER_ENCODING);
+ headers.remove(httpResponseHeader.TRANSFER_ENCODING);
//removing yacy status headers
- headers.remove(httpHeader.X_YACY_KEEP_ALIVE_REQUEST_COUNT);
- headers.remove(httpHeader.X_YACY_ORIGINAL_REQUEST_LINE);
+ headers.remove(httpResponseHeader.X_YACY_KEEP_ALIVE_REQUEST_COUNT);
+ headers.remove(httpResponseHeader.X_YACY_ORIGINAL_REQUEST_LINE);
}
private static void setViaHeader(final httpHeader header, final String httpVer) {
@@ -1268,7 +1261,7 @@ public final class httpdProxyHandler {
}
}
- public static void doConnect(final Properties conProp, final de.anomic.http.httpHeader requestHeader, final InputStream clientIn, final OutputStream clientOut) throws IOException {
+ public static void doConnect(final Properties conProp, final httpRequestHeader requestHeader, final InputStream clientIn, final OutputStream clientOut) throws IOException {
switchboard.proxyLastAccess = System.currentTimeMillis();
diff --git a/source/de/anomic/icap/icapd.java b/source/de/anomic/icap/icapd.java
index 10b393667..601cec805 100644
--- a/source/de/anomic/icap/icapd.java
+++ b/source/de/anomic/icap/icapd.java
@@ -39,13 +39,13 @@ import java.util.Properties;
import de.anomic.http.HttpClient;
import de.anomic.http.httpChunkedInputStream;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
+import de.anomic.http.httpResponseHeader;
import de.anomic.http.httpdProxyCacheEntry;
+import de.anomic.index.indexDocumentMetadata;
import de.anomic.plasma.plasmaHTCache;
import de.anomic.plasma.plasmaParser;
import de.anomic.plasma.plasmaSwitchboard;
-import de.anomic.plasma.cache.IResourceInfo;
-import de.anomic.plasma.cache.http.ResourceInfo;
import de.anomic.server.serverCore;
import de.anomic.server.serverFileUtils;
import de.anomic.server.serverHandler;
@@ -309,11 +309,11 @@ public class icapd implements serverHandler, Cloneable {
// parsing the requestline
final Properties httpReqProps = new Properties();
- httpHeader.parseRequestLine(httpRequestLine,httpReqProps,virtualHost);
+ httpRequestHeader.parseRequestLine(httpRequestLine,httpReqProps,virtualHost);
- if (!httpReqProps.getProperty(httpHeader.CONNECTION_PROP_METHOD).equals(httpHeader.METHOD_GET)) {
+ if (!httpReqProps.getProperty(httpRequestHeader.CONNECTION_PROP_METHOD).equals(httpRequestHeader.METHOD_GET)) {
this.log.logInfo("Wrong http request method for indexing:" +
- "\nRequest Method: " + httpReqProps.getProperty(httpHeader.CONNECTION_PROP_METHOD) +
+ "\nRequest Method: " + httpReqProps.getProperty(httpRequestHeader.CONNECTION_PROP_METHOD) +
"\nRequest Line: " + httpRequestLine);
reader.close();
if(reqHdrStream != null) {
@@ -323,17 +323,18 @@ public class icapd implements serverHandler, Cloneable {
}
// reading all request headers
- final httpHeader httpReqHeader = httpHeader.readHttpHeader(reader);
+ final httpRequestHeader httpReqHeader = new httpRequestHeader();
+ httpReqHeader.readHttpHeader(reader);
reader.close();
if(reqHdrStream != null) {
reqHdrStream.close();
}
// handle transparent proxy support: this function call is needed to set the host property properly
- httpHeader.handleTransparentProxySupport(httpReqHeader,httpReqProps,virtualHost,true);
+ httpRequestHeader.handleTransparentProxySupport(httpReqHeader,httpReqProps,virtualHost,true);
// getting the request URL
- final yacyURL httpRequestURL = httpHeader.getRequestURL(httpReqProps);
+ final yacyURL httpRequestURL = httpRequestHeader.getRequestURL(httpReqProps);
/* =========================================================================
* Parsing response data
@@ -342,7 +343,7 @@ public class icapd implements serverHandler, Cloneable {
reader = new BufferedReader(new InputStreamReader(resHdrStream));
final String httpRespStatusLine = reader.readLine();
- final Object[] httpRespStatus = httpHeader.parseResponseLine(httpRespStatusLine);
+ final Object[] httpRespStatus = httpResponseHeader.parseResponseLine(httpRespStatusLine);
if (!(httpRespStatus[1].equals(Integer.valueOf(200)) || httpRespStatus[1].equals(Integer.valueOf(203)))) {
this.log.logInfo("Wrong status code for indexing:" +
@@ -357,7 +358,8 @@ public class icapd implements serverHandler, Cloneable {
}
// reading all response headers
- final httpHeader httpResHeader = httpHeader.readHttpHeader(reader);
+ final httpResponseHeader httpResHeader = new httpResponseHeader();
+ httpResHeader.readHttpHeader(reader);
reader.close();
if(resHdrStream != null) {
resHdrStream.close();
@@ -376,23 +378,23 @@ public class icapd implements serverHandler, Cloneable {
* ========================================================================= */
// generating a htcache entry object
- final IResourceInfo resInfo = new ResourceInfo(httpRequestURL,httpReqHeader,httpResHeader);
- final httpdProxyCacheEntry cacheEntry = plasmaHTCache.newEntry(
+ final indexDocumentMetadata cacheEntry = new httpdProxyCacheEntry(
0,
httpRequestURL,
"",
httpRespStatusLine,
- resInfo,
+ httpReqHeader, httpResHeader,
null,
switchboard.webIndex.defaultProxyProfile
);
+ plasmaHTCache.storeMetadata(httpResHeader, cacheEntry);
// getting the filename/path to store the response body
final File cacheFile = plasmaHTCache.getCachePath(httpRequestURL);
// if the file already exits we delete it
if (cacheFile.isFile()) {
- plasmaHTCache.deleteURLfromCache(httpRequestURL);
+ plasmaHTCache.deleteURLfromCache(httpRequestURL, false);
}
// we write the new cache entry to file system directly
cacheFile.getParentFile().mkdirs();
diff --git a/source/de/anomic/plasma/cache/IResourceInfo.java b/source/de/anomic/plasma/cache/IResourceInfo.java
deleted file mode 100644
index 589ca9ce7..000000000
--- a/source/de/anomic/plasma/cache/IResourceInfo.java
+++ /dev/null
@@ -1,118 +0,0 @@
-// IResourceInfo.java
-// -------------------------------------
-// part of YACY
-// (C) by Michael Peter Christen; [email protected]
-// first published on http://www.anomic.de
-// Frankfurt, Germany, 2006
-//
-// This file ist contributed by Martin Thelian
-//
-// $LastChangedDate: 2006-02-20 23:57:42 +0100 (Mo, 20 Feb 2006) $
-// $LastChangedRevision: 1715 $
-// $LastChangedBy: theli $
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-package de.anomic.plasma.cache;
-
-import java.util.Date;
-import java.util.TreeMap;
-
-import de.anomic.yacy.yacyURL;
-
-/**
- * A class containing metadata about a downloaded resource
- */
-public interface IResourceInfo {
-
- /**
- * @return the resource information
- */
- public TreeMap<String, String> getMap();
-
- /**
- * @return the URL of this content
- */
- public yacyURL getUrl();
-
- /**
- * Returns the referer URL of this URL
- * @return referer URL
- */
- public yacyURL getRefererUrl();
-
- /**
- * Returns the mimetype of the cached object
- * @return mimetype
- */
- public String getMimeType();
-
- /**
- * Returns the charset of the resource
- * @return returns the name of the charset or <code>null</code> if unknown
- */
- public String getCharacterEncoding();
-
- /**
- * Returns the modification date of the cached object
- * @return the modifiaction date
- */
- public Date getModificationDate();
-
- /**
- * Specifies if the resource was requested with a
- * if modified since date
- * @return the <code>Modified since</code>-header field or <code>null</code>
- * if the request didn't contain this field
- */
- public Date ifModifiedSince();
-
- /**
- * Specifies if the resource was requested with
- * client specific information (e.g. cookies for http)
- * @return whether additional client specific information were passed
- * along the reuqest for this resource
- */
- public boolean requestWithCookie();
-
- /**
- * Specifies if the request prohibits indexing
- * @return whether indexing is proibited by this request
- */
- public boolean requestProhibitsIndexing();
-
- /**
- * Determines if a resource that was downloaded by the crawler
- * is allowed to be indexed.
- *
- * @return an error string describing the reason why the
- * resourse should not be indexed or null if indexing is allowed
- */
- public String shallIndexCacheForCrawler();
-
- /**
- * Determines if a resource that was downloaded by the proxy
- * is allowed to be indexed.
- *
- * @return an error string describing the reason why the
- * resourse should not be indexed or null if indexing is allowed
- */
- public String shallIndexCacheForProxy();
-
- public String shallStoreCacheForProxy();
- public boolean shallUseCacheForProxy();
-
- public boolean validResponseStatus(String responseStatus);
-}
diff --git a/source/de/anomic/plasma/cache/ResourceInfoFactory.java b/source/de/anomic/plasma/cache/ResourceInfoFactory.java
deleted file mode 100644
index 8bf640b4f..000000000
--- a/source/de/anomic/plasma/cache/ResourceInfoFactory.java
+++ /dev/null
@@ -1,81 +0,0 @@
-// RespourceInfoFactory.java
-// -------------------------------------
-// part of YACY
-// (C) by Michael Peter Christen; [email protected]
-// first published on http://www.anomic.de
-// Frankfurt, Germany, 2006
-//
-// This file ist contributed by Martin Thelian
-//
-// $LastChangedDate: 2006-02-20 23:57:42 +0100 (Mo, 20 Feb 2006) $
-// $LastChangedRevision: 1715 $
-// $LastChangedBy: theli $
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-package de.anomic.plasma.cache;
-
-import java.lang.reflect.Constructor;
-import java.util.Map;
-
-import de.anomic.yacy.yacyURL;
-
-
-public class ResourceInfoFactory {
- public IResourceInfo buildResourceInfoObj(
- final yacyURL resourceURL,
- final Map<String, String> resourceMetadata
- ) throws UnsupportedProtocolException, IllegalAccessException {
-
- String protocString = resourceURL.getProtocol();
-
- // TODO: remove this
- if (protocString.equals("https")) protocString = "http";
-
- // the full qualified class name
- final String className = this.getClass().getPackage().getName() + "." + protocString + ".ResourceInfo";
-
- try {
- // loading class by name
- final Class<?> moduleClass = Class.forName(className);
-
- // getting the constructor
- final Constructor<?> classConstructor = moduleClass.getConstructor( new Class[] {
- yacyURL.class,
- Map.class
- } );
-
- // instantiating class
- final IResourceInfo infoObject = (IResourceInfo) classConstructor.newInstance(new Object[] {
- resourceURL,
- resourceMetadata
- });
-
- // return the newly created object
- return infoObject;
- } catch (final Exception e) {
- if (e instanceof RuntimeException) {
- throw (RuntimeException)e;
- } else if (e instanceof ClassNotFoundException) {
- throw new UnsupportedProtocolException(protocString, e);
- } else if (e instanceof IllegalAccessException) {
- throw (IllegalAccessException)e;
- } else {
- e.printStackTrace();
- return null;
- }
- }
- }
-}
diff --git a/source/de/anomic/plasma/cache/UnsupportedProtocolException.java b/source/de/anomic/plasma/cache/UnsupportedProtocolException.java
deleted file mode 100644
index 89f32b076..000000000
--- a/source/de/anomic/plasma/cache/UnsupportedProtocolException.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package de.anomic.plasma.cache;
-
-/**
- * This exception is thrown when a protocol (or a derivative using this protocol) is not
- * supported, as is the case in the {@link ResourceInfoFactory}.
- * @see package {@link de.anomic.plasma.cache} for all {@link IResourceInfo}s available
- */
-public class UnsupportedProtocolException extends Exception {
-
- private static final long serialVersionUID = 1L;
-
- public static final String MESSAGE = "Unsupported protocol error: ";
-
- public UnsupportedProtocolException(final String protocol) {
- super(MESSAGE + protocol);
- }
-
- public UnsupportedProtocolException(final String protocol, final Throwable cause) {
- super(MESSAGE + protocol, cause);
- }
-}
diff --git a/source/de/anomic/plasma/cache/ftp/ResourceInfo.java b/source/de/anomic/plasma/cache/ftp/ResourceInfo.java
deleted file mode 100644
index 82dce34aa..000000000
--- a/source/de/anomic/plasma/cache/ftp/ResourceInfo.java
+++ /dev/null
@@ -1,136 +0,0 @@
-// ResourceInfo.java
-// -------------------------------------
-// part of YACY
-// (C) by Michael Peter Christen; [email protected]
-// first published on http://www.anomic.de
-// Frankfurt, Germany, 2006
-//
-// This file ist contributed by Martin Thelian
-//
-// $LastChangedDate: 2006-02-20 23:57:42 +0100 (Mo, 20 Feb 2006) $
-// $LastChangedRevision: 1715 $
-// $LastChangedBy: theli $
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-package de.anomic.plasma.cache.ftp;
-
-import java.util.Date;
-import java.util.Map;
-import java.util.TreeMap;
-
-import de.anomic.plasma.cache.IResourceInfo;
-import de.anomic.yacy.yacyURL;
-
-public class ResourceInfo implements IResourceInfo {
-
- public static final String MIMETYPE = "mimetype";
- public static final String MODIFICATION_DATE = "modificationDate";
-
- private final yacyURL objectURL;
- private yacyURL refererURL;
- private final TreeMap<String, String> propertyMap;
-
- /**
- * Constructor used by the {@link ResourceInfoFactory}
- * @param objectURL
- * @param objectInfo
- */
- public ResourceInfo(final yacyURL objectURL, final Map<String, String> objectInfo) {
- if (objectURL == null) throw new NullPointerException();
- if (objectInfo == null) throw new NullPointerException();
-
- // generating the url hash
- this.objectURL = objectURL;
- this.refererURL = null;
-
- // create the http header object
- this.propertyMap = new TreeMap<String, String>(objectInfo);
- }
-
- public ResourceInfo(final yacyURL objectURL, final yacyURL refererUrl, final String mimeType, final Date fileDate) {
- if (objectURL == null) throw new NullPointerException();
-
- // generating the url hash
- this.objectURL = objectURL;
-
- // create the http header object
- this.propertyMap = new TreeMap<String, String>();
- if (refererUrl != null)
- this.refererURL = refererUrl;
- if (mimeType != null)
- this.propertyMap.put(MIMETYPE, mimeType);
- if (fileDate != null)
- this.propertyMap.put(MODIFICATION_DATE, Long.toString(fileDate.getTime()));
- }
-
- public TreeMap<String, String> getMap() {
- return this.propertyMap;
- }
-
- public String getMimeType() {
- return ((this.propertyMap == null) ? null : this.propertyMap.get(MIMETYPE));
- }
-
- public Date getModificationDate() {
- if (this.propertyMap == null || !this.propertyMap.containsKey(MODIFICATION_DATE)) return new Date();
- return new Date(Long.valueOf(this.propertyMap.get(MODIFICATION_DATE)).longValue());
- }
-
- public yacyURL getRefererUrl() {
- return this.refererURL;
- }
-
- public yacyURL getUrl() {
- return this.objectURL;
- }
-
- public Date ifModifiedSince() {
- return null;
- }
-
- public boolean requestProhibitsIndexing() {
- return false;
- }
-
- public boolean requestWithCookie() {
- return false;
- }
-
- public String shallIndexCacheForCrawler() {
- return null;
- }
-
- public String shallIndexCacheForProxy() {
- return null;
- }
-
- public String shallStoreCacheForProxy() {
- return null;
- }
-
- public boolean shallUseCacheForProxy() {
- return false;
- }
-
- public boolean validResponseStatus(final String responseStatus) {
- return responseStatus != null && responseStatus.equalsIgnoreCase("OK");
- }
-
- public String getCharacterEncoding() {
- return null;
- }
-
-}
diff --git a/source/de/anomic/plasma/cache/http/ResourceInfo.java b/source/de/anomic/plasma/cache/http/ResourceInfo.java
deleted file mode 100644
index c8bc27b1e..000000000
--- a/source/de/anomic/plasma/cache/http/ResourceInfo.java
+++ /dev/null
@@ -1,451 +0,0 @@
-// ResourceInfo.java
-// -------------------------------------
-// part of YACY
-// (C) by Michael Peter Christen; [email protected]
-// first published on http://www.anomic.de
-// Frankfurt, Germany, 2006
-//
-// This file ist contributed by Martin Thelian
-//
-// $LastChangedDate: 2006-02-20 23:57:42 +0100 (Mo, 20 Feb 2006) $
-// $LastChangedRevision: 1715 $
-// $LastChangedBy: theli $
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-package de.anomic.plasma.cache.http;
-
-import java.util.Date;
-import java.util.Map;
-import java.util.TreeMap;
-
-import de.anomic.http.httpHeader;
-import de.anomic.plasma.plasmaHTCache;
-import de.anomic.plasma.cache.IResourceInfo;
-import de.anomic.server.serverDate;
-import de.anomic.yacy.yacyURL;
-
-public class ResourceInfo implements IResourceInfo {
- private final yacyURL url;
- private final httpHeader responseHeader;
- private httpHeader requestHeader;
-
- /**
- * Constructor used by the {@link ResourceInfoFactory}
- * @param objectURL
- * @param objectInfo
- */
- public ResourceInfo(final yacyURL objectURL, final Map<String, String> objectInfo) {
- if (objectURL == null) throw new NullPointerException();
- if (objectInfo == null) throw new NullPointerException();
-
- // generating the url hash
- this.url = objectURL;
-
- // create the http header object
- this.responseHeader = new httpHeader(null, objectInfo);
- }
-
- public ResourceInfo(final yacyURL objectURL, final httpHeader requestHeaders, final httpHeader responseHeaders) {
- if (objectURL == null) throw new NullPointerException("objectURL == null");
- if (responseHeaders == null) throw new NullPointerException("responseHeader == null");
-
- // generating the url hash
- this.url = objectURL;
-
- this.requestHeader = requestHeaders;
- this.responseHeader = responseHeaders;
- }
-
- public TreeMap<String, String> getMap() {
- return this.responseHeader;
- }
-
- /**
- * @see de.anomic.plasma.cache.IResourceInfo#getMimeType()
- */
- public String getMimeType() {
- if (this.responseHeader == null) return null;
-
- String mimeType = this.responseHeader.mime();
- mimeType = mimeType.trim().toLowerCase();
-
- final int pos = mimeType.indexOf(';');
- return ((pos < 0) ? mimeType : mimeType.substring(0, pos));
- }
-
- public String getCharacterEncoding() {
- if (this.responseHeader == null) return null;
- return this.responseHeader.getCharacterEncoding();
- }
-
- /**
- * @see de.anomic.plasma.cache.IResourceInfo#getModificationDate()
- */
- public Date getModificationDate() {
- Date docDate = null;
-
- if (this.responseHeader != null) {
- docDate = this.responseHeader.lastModified();
- if (docDate == null) docDate = this.responseHeader.date();
- }
- if (docDate == null) docDate = new Date(serverDate.correctedUTCTime());
-
- return docDate;
- }
-
- public yacyURL getRefererUrl() {
- if (this.requestHeader == null) return null;
- try {
- return new yacyURL((String) this.requestHeader.get(httpHeader.REFERER, ""), null);
- } catch (final Exception e) {
- return null;
- }
- }
-
- /**
- * @see de.anomic.plasma.cache.IResourceInfo#getUrl()
- */
- public yacyURL getUrl() {
- return this.url;
- }
-
- /**
- * @see de.anomic.plasma.cache.IResourceInfo#getUrlHash()
- */
- public String getUrlHash() {
- return this.url.hash();
- }
-
- public void setRequestHeader(final httpHeader reqestHeader) {
- this.requestHeader = reqestHeader;
- }
-
- /**
- * @see de.anomic.plasma.cache.IResourceInfo#shallIndexCacheForCrawler()
- */
- public String shallIndexCacheForCrawler() {
- final String mimeType = this.getMimeType();
- if (plasmaHTCache.isPicture(mimeType)) { return "Media_Content_(Picture)"; }
- if (!plasmaHTCache.isText(mimeType)) { return "Media_Content_(not_text)"; }
- return null;
- }
-
- /**
- * @see de.anomic.plasma.cache.IResourceInfo#shallIndexCacheForProxy()
- */
- public String shallIndexCacheForProxy() {
- // -set-cookie in response
- // the set-cookie from the server does not indicate that the content is special
- // thus we do not care about it here for indexing
-
- // a picture cannot be indexed
- final String mimeType = this.getMimeType();
- if (plasmaHTCache.isPicture(mimeType)) {
- return "Media_Content_(Picture)";
- }
- if (!plasmaHTCache.isText(mimeType)) {
- return "Media_Content_(not_text)";
- }
-
- // -if-modified-since in request
- // if the page is fresh at the very moment we can index it
- final Date ifModifiedSince = getModificationDate();
- if ((ifModifiedSince != null) && (this.responseHeader.containsKey(httpHeader.LAST_MODIFIED))) {
- // parse date
- Date d = this.responseHeader.lastModified();
- if (d == null) {
- d = new Date(serverDate.correctedUTCTime());
- }
- // finally, we shall treat the cache as stale if the modification time is after the if-.. time
- if (d.after(ifModifiedSince)) {
- //System.out.println("***not indexed because if-modified-since");
- return "Stale_(Last-Modified>Modified-Since)";
- }
- }
-
- // -pragma in cached response
- if (this.responseHeader.containsKey(httpHeader.PRAGMA) &&
- (this.responseHeader.get(httpHeader.PRAGMA)).toUpperCase().equals("NO-CACHE")) {
- return "Denied_(pragma_no_cache)";
- }
-
- // see for documentation also:
- // http://www.web-caching.com/cacheability.html
-
- // look for freshnes information
-
- // -expires in cached response
- // the expires value gives us a very easy hint when the cache is stale
- // sometimes, the expires date is set to the past to prevent that a page is cached
- // we use that information to see if we should index it
- final Date expires = this.responseHeader.expires();
- if (expires != null && expires.before(new Date(serverDate.correctedUTCTime()))) {
- return "Stale_(Expired)";
- }
-
- // -lastModified in cached response
- // this information is too weak to use it to prevent indexing
- // even if we can apply a TTL heuristic for cache usage
-
- // -cache-control in cached response
- // the cache-control has many value options.
- String cacheControl = this.responseHeader.get(httpHeader.CACHE_CONTROL);
- if (cacheControl != null) {
- cacheControl = cacheControl.trim().toUpperCase();
- /* we have the following cases for cache-control:
- "public" -- can be indexed
- "private", "no-cache", "no-store" -- cannot be indexed
- "max-age=<delta-seconds>" -- stale/fresh dependent on date
- */
- if (cacheControl.startsWith("PRIVATE") ||
- cacheControl.startsWith("NO-CACHE") ||
- cacheControl.startsWith("NO-STORE")) {
- // easy case
- return "Stale_(denied_by_cache-control=" + cacheControl + ")";
-// } else if (cacheControl.startsWith("PUBLIC")) {
-// // ok, do nothing
- } else if (cacheControl.startsWith("MAX-AGE=")) {
- // we need also the load date
- final Date date = this.responseHeader.date();
- if (date == null) {
- return "Stale_(no_date_given_in_response)";
- }
- try {
- final long ttl = 1000 * Long.parseLong(cacheControl.substring(8)); // milliseconds to live
- if (serverDate.correctedUTCTime() - date.getTime() > ttl) {
- //System.out.println("***not indexed because cache-control");
- return "Stale_(expired_by_cache-control)";
- }
- } catch (final Exception e) {
- return "Error_(" + e.getMessage() + ")";
- }
- }
- }
- return null;
- }
-
- public String shallStoreCacheForProxy() {
- if (this.requestHeader != null) {
- // -authorization cases in request
- // authorization makes pages very individual, and therefore we cannot use the
- // content in the cache
- if (this.requestHeader.containsKey(httpHeader.AUTHORIZATION)) { return "personalized"; }
- // -ranges in request and response
- // we do not cache partial content
- if (this.requestHeader.containsKey(httpHeader.RANGE)) { return "partial"; }
- }
-
- if (this.responseHeader != null) {
- // -ranges in request and response
- // we do not cache partial content
- if (this.responseHeader.containsKey(httpHeader.CONTENT_RANGE)) { return "partial"; }
-
- // -if-modified-since in request
- // we do not care about if-modified-since, because this case only occurres if the
- // cache file does not exist, and we need as much info as possible for the indexing
-
- // -cookies in request
- // we do not care about cookies, because that would prevent loading more pages
- // from one domain once a request resulted in a client-side stored cookie
-
- // -set-cookie in response
- // we do not care about cookies in responses, because that info comes along
- // any/many pages from a server and does not express the validity of the page
- // in modes of life-time/expiration or individuality
-
- // -pragma in response
- // if we have a pragma non-cache, we don't cache. usually if this is wanted from
- // the server, it makes sense
- String cacheControl = this.responseHeader.get(httpHeader.PRAGMA);
- if (cacheControl != null && cacheControl.trim().toUpperCase().equals("NO-CACHE")) { return "controlled_no_cache"; }
-
- // -expires in response
- // we do not care about expires, because at the time this is called the data is
- // obvious valid and that header info is used in the indexing later on
-
- // -cache-control in response
- // the cache-control has many value options.
- cacheControl = this.responseHeader.get(httpHeader.CACHE_CONTROL);
- if (cacheControl != null) {
- cacheControl = cacheControl.trim().toUpperCase();
- if (cacheControl.startsWith("MAX-AGE=")) {
- // we need also the load date
- final Date date = this.responseHeader.date();
- if (date == null) return "stale_no_date_given_in_response";
- try {
- final long ttl = 1000 * Long.parseLong(cacheControl.substring(8)); // milliseconds to live
- if (serverDate.correctedUTCTime() - date.getTime() > ttl) {
- //System.out.println("***not indexed because cache-control");
- return "stale_expired";
- }
- } catch (final Exception e) {
- return "stale_error_" + e.getMessage() + ")";
- }
- }
- }
- }
- return null;
- }
-
- public boolean shallUseCacheForProxy() {
-
- String cacheControl;
- if (this.requestHeader != null) {
- // -authorization cases in request
- if (this.requestHeader.containsKey(httpHeader.AUTHORIZATION)) { return false; }
-
- // -ranges in request
- // we do not cache partial content
- if (this.requestHeader.containsKey(httpHeader.RANGE)) { return false; }
-
- // if the client requests a un-cached copy of the resource ...
- cacheControl = this.requestHeader.get(httpHeader.PRAGMA);
- if (cacheControl != null && cacheControl.trim().toUpperCase().equals("NO-CACHE")) { return false; }
-
- cacheControl = this.requestHeader.get(httpHeader.CACHE_CONTROL);
- if (cacheControl != null) {
- cacheControl = cacheControl.trim().toUpperCase();
- if (cacheControl.startsWith("NO-CACHE") || cacheControl.startsWith("MAX-AGE=0")) { return false; }
- }
-
- // -if-modified-since in request
- // The entity has to be transferred only if it has
- // been modified since the date given by the If-Modified-Since header.
- if (this.requestHeader.containsKey(httpHeader.IF_MODIFIED_SINCE)) {
- // checking this makes only sense if the cached response contains
- // a Last-Modified field. If the field does not exist, we go the safe way
- if (!this.responseHeader.containsKey(httpHeader.LAST_MODIFIED)) { return false; }
- // parse date
- Date d1, d2;
- d2 = this.responseHeader.lastModified(); if (d2 == null) { d2 = new Date(serverDate.correctedUTCTime()); }
- d1 = this.requestHeader.ifModifiedSince(); if (d1 == null) { d1 = new Date(serverDate.correctedUTCTime()); }
- // finally, we shall treat the cache as stale if the modification time is after the if-.. time
- if (d2.after(d1)) { return false; }
- }
-
- final String mimeType = this.getMimeType();
- if (!plasmaHTCache.isPicture(mimeType)) {
- // -cookies in request
- // unfortunately, we should reload in case of a cookie
- // but we think that pictures can still be considered as fresh
- // -set-cookie in cached response
- // this is a similar case as for COOKIE.
- if (this.requestHeader.containsKey(httpHeader.COOKIE) ||
- this.responseHeader.containsKey(httpHeader.SET_COOKIE) ||
- this.responseHeader.containsKey(httpHeader.SET_COOKIE2)) {
- return false; // too strong
- }
- }
- }
-
- // -pragma in cached response
- // logically, we would not need to care about no-cache pragmas in cached response headers,
- // because they cannot exist since they are not written to the cache.
- // So this IF should always fail..
- cacheControl = this.responseHeader.get(httpHeader.PRAGMA);
- if (cacheControl != null && cacheControl.trim().toUpperCase().equals("NO-CACHE")) { return false; }
-
- // see for documentation also:
- // http://www.web-caching.com/cacheability.html
- // http://vancouver-webpages.com/CacheNow/
-
- // look for freshnes information
- // if we don't have any freshnes indication, we treat the file as stale.
- // no handle for freshness control:
-
- // -expires in cached response
- // the expires value gives us a very easy hint when the cache is stale
- final Date expires = this.responseHeader.expires();
- if (expires != null) {
-// System.out.println("EXPIRES-TEST: expires=" + expires + ", NOW=" + serverDate.correctedGMTDate() + ", url=" + url);
- if (expires.before(new Date(serverDate.correctedUTCTime()))) { return false; }
- }
- final Date lastModified = this.responseHeader.lastModified();
- cacheControl = this.responseHeader.get(httpHeader.CACHE_CONTROL);
- if (cacheControl == null && lastModified == null && expires == null) { return false; }
-
- // -lastModified in cached response
- // we can apply a TTL (Time To Live) heuristic here. We call the time delta between the last read
- // of the file and the last modified date as the age of the file. If we consider the file as
- // middel-aged then, the maximum TTL would be cache-creation plus age.
- // This would be a TTL factor of 100% we want no more than 10% TTL, so that a 10 month old cache
- // file may only be treated as fresh for one more month, not more.
- Date date = this.responseHeader.date();
- if (lastModified != null) {
- if (date == null) { date = new Date(serverDate.correctedUTCTime()); }
- final long age = date.getTime() - lastModified.getTime();
- if (age < 0) { return false; }
- // TTL (Time-To-Live) is age/10 = (d2.getTime() - d1.getTime()) / 10
- // the actual living-time is serverDate.correctedGMTDate().getTime() - d2.getTime()
- // therefore the cache is stale, if serverDate.correctedGMTDate().getTime() - d2.getTime() > age/10
- if (serverDate.correctedUTCTime() - date.getTime() > age / 10) { return false; }
- }
-
- // -cache-control in cached response
- // the cache-control has many value options.
- if (cacheControl != null) {
- cacheControl = cacheControl.trim().toUpperCase();
- if (cacheControl.startsWith("PRIVATE") ||
- cacheControl.startsWith("NO-CACHE") ||
- cacheControl.startsWith("NO-STORE")) {
- // easy case
- return false;
-// } else if (cacheControl.startsWith("PUBLIC")) {
-// // ok, do nothing
- } else if (cacheControl.startsWith("MAX-AGE=")) {
- // we need also the load date
- if (date == null) { return false; }
- try {
- final long ttl = 1000 * Long.parseLong(cacheControl.substring(8)); // milliseconds to live
- if (serverDate.correctedUTCTime() - date.getTime() > ttl) {
- return false;
- }
- } catch (final Exception e) {
- return false;
- }
- }
- }
- return true;
- }
-
- public boolean validResponseStatus(final String responseStatus) {
- return responseStatus.startsWith("200") ||
- responseStatus.startsWith("203");
- }
-
- public Date ifModifiedSince() {
- return (this.requestHeader == null) ? null : this.requestHeader.ifModifiedSince();
- }
-
- public boolean requestWithCookie() {
- return (this.requestHeader == null) ? false : this.requestHeader.containsKey(httpHeader.COOKIE);
- }
-
- public boolean requestProhibitsIndexing() {
- return (this.requestHeader == null)
- ? false
- : this.requestHeader.containsKey(httpHeader.X_YACY_INDEX_CONTROL) &&
- (this.requestHeader.get(httpHeader.X_YACY_INDEX_CONTROL)).toUpperCase().equals("NO-INDEX");
- }
-
- public httpHeader getRequestHeader() {
- return this.requestHeader;
- }
-
- public httpHeader getResponseHeader() {
- return this.responseHeader;
- }
-}
diff --git a/source/de/anomic/plasma/parser/odt/odtParser.java b/source/de/anomic/plasma/parser/odt/odtParser.java
index b290f0e62..06d43d635 100644
--- a/source/de/anomic/plasma/parser/odt/odtParser.java
+++ b/source/de/anomic/plasma/parser/odt/odtParser.java
@@ -42,7 +42,7 @@ import com.catcode.odf.OpenDocumentTextInputStream;
import de.anomic.crawler.HTTPLoader;
import de.anomic.http.HttpClient;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaParserDocument;
import de.anomic.plasma.parser.AbstractParser;
import de.anomic.plasma.parser.Parser;
@@ -234,8 +234,8 @@ public class odtParser extends AbstractParser implements Parser {
testParser.setLogger(new serverLog("PARSER.ODT"));
// downloading the document content
- final httpHeader reqHeader = new httpHeader();
- reqHeader.put(httpHeader.USER_AGENT, HTTPLoader.crawlerUserAgent);
+ final httpRequestHeader reqHeader = new httpRequestHeader();
+ reqHeader.put(httpRequestHeader.USER_AGENT, HTTPLoader.crawlerUserAgent);
final byte[] content = HttpClient.wget(contentUrl.toString(), reqHeader, 10000);
final ByteArrayInputStream input = new ByteArrayInputStream(content);
diff --git a/source/de/anomic/plasma/parser/rpm/rpmParser.java b/source/de/anomic/plasma/parser/rpm/rpmParser.java
index 742289e24..4f6b92e62 100644
--- a/source/de/anomic/plasma/parser/rpm/rpmParser.java
+++ b/source/de/anomic/plasma/parser/rpm/rpmParser.java
@@ -35,7 +35,7 @@ import com.jguild.jrpm.io.datatype.DataTypeIf;
import de.anomic.crawler.HTTPLoader;
import de.anomic.http.HttpClient;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaParserDocument;
import de.anomic.plasma.parser.AbstractParser;
import de.anomic.plasma.parser.Parser;
@@ -163,8 +163,8 @@ public class rpmParser extends AbstractParser implements Parser {
final yacyURL contentUrl = new yacyURL(args[0], null);
final rpmParser testParser = new rpmParser();
- final httpHeader reqHeader = new httpHeader();
- reqHeader.put(httpHeader.USER_AGENT, HTTPLoader.crawlerUserAgent);
+ final httpRequestHeader reqHeader = new httpRequestHeader();
+ reqHeader.put(httpRequestHeader.USER_AGENT, HTTPLoader.crawlerUserAgent);
final byte[] content = HttpClient.wget(contentUrl.toString(), reqHeader, 10000);
final ByteArrayInputStream input = new ByteArrayInputStream(content);
testParser.parse(contentUrl, "application/x-rpm", null, input);
diff --git a/source/de/anomic/plasma/parser/vcf/vcfParser.java b/source/de/anomic/plasma/parser/vcf/vcfParser.java
index cb8c3e92c..d66c68b8b 100644
--- a/source/de/anomic/plasma/parser/vcf/vcfParser.java
+++ b/source/de/anomic/plasma/parser/vcf/vcfParser.java
@@ -36,7 +36,7 @@ import java.util.LinkedList;
import de.anomic.crawler.HTTPLoader;
import de.anomic.http.HttpClient;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.kelondro.kelondroBase64Order;
import de.anomic.plasma.plasmaParserDocument;
import de.anomic.plasma.parser.AbstractParser;
@@ -274,8 +274,8 @@ public class vcfParser extends AbstractParser implements Parser {
final yacyURL contentUrl = new yacyURL(args[0], null);
final vcfParser testParser = new vcfParser();
- final httpHeader reqHeader = new httpHeader();
- reqHeader.put(httpHeader.USER_AGENT, HTTPLoader.crawlerUserAgent);
+ final httpRequestHeader reqHeader = new httpRequestHeader();
+ reqHeader.put(httpRequestHeader.USER_AGENT, HTTPLoader.crawlerUserAgent);
final byte[] content = HttpClient.wget(contentUrl.toString(), reqHeader, 10000);
final ByteArrayInputStream input = new ByteArrayInputStream(content);
testParser.parse(contentUrl, "text/x-vcard", "UTF-8",input);
diff --git a/source/de/anomic/plasma/plasmaHTCache.java b/source/de/anomic/plasma/plasmaHTCache.java
index c364c6ba8..cdb61a53e 100644
--- a/source/de/anomic/plasma/plasmaHTCache.java
+++ b/source/de/anomic/plasma/plasmaHTCache.java
@@ -50,18 +50,14 @@ import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import de.anomic.crawler.CrawlProfile;
-import de.anomic.http.httpHeader;
-import de.anomic.http.httpdProxyCacheEntry;
+import de.anomic.http.httpResponseHeader;
+import de.anomic.index.indexDocumentMetadata;
import de.anomic.kelondro.kelondroBLOB;
import de.anomic.kelondro.kelondroBLOBHeap;
import de.anomic.kelondro.kelondroBLOBTree;
import de.anomic.kelondro.kelondroBase64Order;
import de.anomic.kelondro.kelondroMScoreCluster;
import de.anomic.kelondro.kelondroMap;
-import de.anomic.plasma.cache.IResourceInfo;
-import de.anomic.plasma.cache.ResourceInfoFactory;
-import de.anomic.plasma.cache.UnsupportedProtocolException;
import de.anomic.server.serverCodings;
import de.anomic.server.serverDomains;
import de.anomic.server.serverFileUtils;
@@ -81,7 +77,7 @@ public final class plasmaHTCache {
public static final long oneday = 1000 * 60 * 60 * 24; // milliseconds of a day
private static kelondroMap responseHeaderDB = null;
- private static final ConcurrentLinkedQueue<httpdProxyCacheEntry> cacheStack = new ConcurrentLinkedQueue<httpdProxyCacheEntry>();
+ private static final ConcurrentLinkedQueue<indexDocumentMetadata> cacheStack = new ConcurrentLinkedQueue<indexDocumentMetadata>();
private static final SortedMap<String, File> cacheAge = Collections.synchronizedSortedMap(new TreeMap<String, File>()); // a <date+hash, cache-path> - relation
public static long curCacheSize = 0;
public static long maxCacheSize = 0l;
@@ -89,7 +85,6 @@ public final class plasmaHTCache {
public static final serverLog log = new serverLog("HTCACHE");
private static long lastcleanup = System.currentTimeMillis();
- private static ResourceInfoFactory objFactory = new ResourceInfoFactory();
private static serverThread cacheScanThread = null;
// URL attributes
@@ -217,11 +212,11 @@ public final class plasmaHTCache {
return responseHeaderDB.size();
}
- public static void push(final httpdProxyCacheEntry entry) {
+ public static void push(final indexDocumentMetadata entry) {
cacheStack.add(entry);
}
- public static httpdProxyCacheEntry pop() {
+ public static indexDocumentMetadata pop() {
return cacheStack.poll();
}
@@ -241,58 +236,6 @@ public final class plasmaHTCache {
return (curCacheSize >= maxCacheSize) ? 0 : maxCacheSize - curCacheSize;
}
- public static boolean writeResourceContent(final yacyURL url, final byte[] array) {
- if (array == null) return false;
- final File file = getCachePath(url);
- try {
- deleteFile(file);
- file.getParentFile().mkdirs();
- serverFileUtils.copy(array, file);
- } catch (final FileNotFoundException e) {
- // this is the case of a "(Not a directory)" error, which should be prohibited
- // by the shallStoreCache() property. However, sometimes the error still occurs
- // In this case do nothing.
- log.logSevere("File storage failed (not a directory): " + e.getMessage());
- return false;
- } catch (final IOException e) {
- log.logSevere("File storage failed (IO error): " + e.getMessage());
- return false;
- }
- writeFileAnnouncement(file);
- return true;
- }
-
- public static void writeFileAnnouncement(final File file) {
- if (file.exists()) {
- curCacheSize += file.length();
- if (System.currentTimeMillis() - lastcleanup > 300000) {
- // call the cleanup job only every 5 minutes
- cleanup();
- lastcleanup = System.currentTimeMillis();
- }
- cacheAge.put(ageString(file.lastModified(), file), file);
- }
- }
-
- public static boolean deleteURLfromCache(final yacyURL url) {
- return deleteURLfromCache(url, false);
- }
-
- public static boolean deleteURLfromCache(final yacyURL url, final boolean keepHeader) {
- if (deleteFileandDirs(getCachePath(url), "FROM") && !keepHeader) {
- try {
- // As the file is gone, the entry in responseHeader.db is not needed anymore
- if (log.isFinest()) log.logFinest("Trying to remove responseHeader from URL: " + url.toNormalform(false, true));
- responseHeaderDB.remove(url.hash());
- } catch (final IOException e) {
- resetResponseHeaderDB();
- log.logWarning("IOExeption removing response header from DB: " + e.getMessage(), e);
- }
- return true;
- }
- return false;
- }
-
private static boolean deleteFile(final File obj) {
if (obj.exists()) {
final long size = obj.length();
@@ -467,35 +410,6 @@ public final class plasmaHTCache {
return prefix + s.substring(0, p);
}
- /**
- * Returns an object containing metadata about a cached resource
- * @param url the {@link URL} of the resource
- * @return an {@link IResourceInfo info object}
- * @throws <b>IllegalAccessException</b> if the {@link SecurityManager} doesn't allow instantiation
- * of the info object with the given protocol
- * @throws <b>UnsupportedProtocolException</b> if the protocol is not supported and therefore the
- * info object couldn't be created
- */
- public static IResourceInfo loadResourceInfo(final yacyURL url) throws UnsupportedProtocolException, IllegalAccessException {
-
- // loading data from database
- Map<String, String> hdb;
- try {
- hdb = responseHeaderDB.get(url.hash());
- } catch (final IOException e) {
- return null;
- }
- if (hdb == null) return null;
-
- // generate the cached object
- final IResourceInfo cachedObj = objFactory.buildResourceInfoObj(url, hdb);
- return cachedObj;
- }
-
- public static ResourceInfoFactory getResourceInfoFactory() {
- return objFactory;
- }
-
public static boolean full() {
return (cacheStack.size() > stackLimit);
}
@@ -510,10 +424,6 @@ public final class plasmaHTCache {
}
public static boolean isText(final String mimeType) {
-// Object ct = response.get(httpHeader.CONTENT_TYPE);
-// if (ct == null) return false;
-// String t = ((String)ct).toLowerCase();
-// return ((t.startsWith("text")) || (t.equals("application/xhtml+xml")));
return plasmaParser.supportedMimeTypesContains(mimeType);
}
@@ -675,7 +585,7 @@ public final class plasmaHTCache {
hdb = null;
}
if (hdb != null) {
- final Object origRequestLine = hdb.get(httpHeader.X_YACY_ORIGINAL_REQUEST_LINE);
+ final Object origRequestLine = hdb.get(httpResponseHeader.X_YACY_ORIGINAL_REQUEST_LINE);
if ((origRequestLine != null)&&(origRequestLine instanceof String)) {
int i = ((String)origRequestLine).indexOf(" ");
if (i >= 0) {
@@ -777,6 +687,116 @@ public final class plasmaHTCache {
return null;
}
+ /**
+ * @return the responseHeaderDB
+ */
+ static kelondroMap getResponseHeaderDB() {
+ return responseHeaderDB;
+ }
+
+
+ /*
+ * ACCESS METHODS
+ */
+
+
+ // Store to Cache
+
+ public static void storeMetadata(
+ final httpResponseHeader responseHeader,
+ indexDocumentMetadata metadata
+ ) {
+ if (responseHeader != null) try {
+ // store the response header into the header database
+ final HashMap<String, String> hm = new HashMap<String, String>();
+ hm.putAll(responseHeader);
+ hm.put("@@URL", metadata.url().toNormalform(false, false));
+ hm.put("@@DEPTH", Integer.toString(metadata.depth()));
+ if (metadata.initiator() != null) hm.put("@@INITIATOR", metadata.initiator());
+ responseHeaderDB.put(metadata.urlHash(), hm);
+ } catch (final Exception e) {
+ log.logWarning("could not write ResourceInfo: "
+ + e.getClass() + ": " + e.getMessage());
+ resetResponseHeaderDB();
+ }
+ }
+
+ public static boolean writeResourceContent(final yacyURL url, final byte[] array) {
+ if (array == null) return false;
+ final File file = getCachePath(url);
+ try {
+ deleteFile(file);
+ file.getParentFile().mkdirs();
+ serverFileUtils.copy(array, file);
+ } catch (final FileNotFoundException e) {
+ // this is the case of a "(Not a directory)" error, which should be prohibited
+ // by the shallStoreCache() property. However, sometimes the error still occurs
+ // In this case do nothing.
+ log.logSevere("File storage failed (not a directory): " + e.getMessage());
+ return false;
+ } catch (final IOException e) {
+ log.logSevere("File storage failed (IO error): " + e.getMessage());
+ return false;
+ }
+ writeFileAnnouncement(file);
+ return true;
+ }
+
+ public static void writeFileAnnouncement(final File file) {
+ if (file.exists()) {
+ curCacheSize += file.length();
+ if (System.currentTimeMillis() - lastcleanup > 300000) {
+ // call the cleanup job only every 5 minutes
+ cleanup();
+ lastcleanup = System.currentTimeMillis();
+ }
+ cacheAge.put(ageString(file.lastModified(), file), file);
+ }
+ }
+
+ // Delete from Cache
+
+ public static boolean deleteURLfromCache(final yacyURL url, final boolean keepHeader) {
+ if (deleteFileandDirs(getCachePath(url), "FROM") && !keepHeader) {
+ try {
+ // As the file is gone, the entry in responseHeader.db is not needed anymore
+ if (log.isFinest()) log.logFinest("Trying to remove responseHeader from URL: " + url.toNormalform(false, true));
+ responseHeaderDB.remove(url.hash());
+ } catch (final IOException e) {
+ resetResponseHeaderDB();
+ log.logWarning("IOExeption removing response header from DB: " + e.getMessage(), e);
+ }
+ return true;
+ }
+ return false;
+ }
+
+
+ // Read from Cache
+
+ /**
+ * Returns an object containing metadata about a cached resource
+ * @param url the {@link URL} of the resource
+ * @return an {@link IResourceInfo info object}
+ * @throws <b>IllegalAccessException</b> if the {@link SecurityManager} doesn't allow instantiation
+ * of the info object with the given protocol
+ * @throws <b>UnsupportedProtocolException</b> if the protocol is not supported and therefore the
+ * info object couldn't be created
+ */
+ public static httpResponseHeader loadResponseHeader(final yacyURL url) throws IllegalAccessException {
+
+ // loading data from database
+ Map<String, String> hdb;
+ try {
+ hdb = responseHeaderDB.get(url.hash());
+ } catch (final IOException e) {
+ return null;
+ }
+ if (hdb == null) return null;
+
+ return new httpResponseHeader(null, hdb);
+ }
+
/**
* Returns the content of a cached resource as {@link InputStream}
* @param url the requested resource
@@ -805,46 +825,5 @@ public final class plasmaHTCache {
return 0;
}
- public static httpdProxyCacheEntry newEntry(
- final int depth,
- final yacyURL url,
- final String name,
- final String responseStatus,
- final IResourceInfo docInfo,
- final String initiator,
- final CrawlProfile.entry profile
- ) {
- final httpdProxyCacheEntry entry = new httpdProxyCacheEntry(
- depth,
- url,
- name,
- responseStatus,
- docInfo,
- initiator,
- profile
- );
- if (docInfo != null) try {
- final HashMap<String, String> hm = new HashMap<String, String>();
- hm.putAll(docInfo.getMap());
- hm.put("@@URL", url.toNormalform(false, false));
- hm.put("@@DEPTH", Integer.toString(depth));
- if (initiator != null)
- hm.put("@@INITIATOR", initiator);
- plasmaHTCache.getResponseHeaderDB().put(url.hash(), hm);
- } catch (final Exception e) {
- plasmaHTCache.log.logWarning("could not write ResourceInfo: "
- + e.getClass() + ": " + e.getMessage());
- plasmaHTCache.resetResponseHeaderDB();
- }
-
- return entry;
- }
-
- /**
- * @return the responseHeaderDB
- */
- static kelondroMap getResponseHeaderDB() {
- return responseHeaderDB;
- }
-
+
}
diff --git a/source/de/anomic/plasma/plasmaParser.java b/source/de/anomic/plasma/plasmaParser.java
index b3212e0f6..3bc8e9c90 100644
--- a/source/de/anomic/plasma/plasmaParser.java
+++ b/source/de/anomic/plasma/plasmaParser.java
@@ -899,7 +899,7 @@ public final class plasmaParser {
content = res.getDataAsStream();
contentMimeType = res.getResponseHeader().mime();
charSet = res.getResponseHeader().getCharacterEncoding();
- contentLength = res.getResponseHeader().contentLength();
+ contentLength = res.getResponseHeader().getContentLength();
}
if ((args.length >= 4)&&(args[2].equalsIgnoreCase("-m"))) {
diff --git a/source/de/anomic/plasma/plasmaSnippetCache.java b/source/de/anomic/plasma/plasmaSnippetCache.java
index fb42c03a3..ab7d4f7cc 100644
--- a/source/de/anomic/plasma/plasmaSnippetCache.java
+++ b/source/de/anomic/plasma/plasmaSnippetCache.java
@@ -38,13 +38,12 @@ import java.util.TreeSet;
import de.anomic.htmlFilter.htmlFilterImageEntry;
import de.anomic.http.HttpClient;
-import de.anomic.http.httpHeader;
-import de.anomic.http.httpdProxyCacheEntry;
+import de.anomic.http.httpResponseHeader;
+import de.anomic.index.indexDocumentMetadata;
import de.anomic.index.indexURLReference;
import de.anomic.index.indexWord;
import de.anomic.kelondro.kelondroMScoreCluster;
import de.anomic.kelondro.kelondroMSetTools;
-import de.anomic.plasma.cache.IResourceInfo;
import de.anomic.plasma.parser.ParserException;
import de.anomic.server.logging.serverLog;
import de.anomic.yacy.yacySearch;
@@ -258,10 +257,11 @@ public class plasmaSnippetCache {
// if the snippet is not in the cache, we can try to get it from the htcache
long resContentLength = 0;
InputStream resContent = null;
- IResourceInfo resInfo = null;
+ httpResponseHeader responseHeader = null;
try {
// trying to load the resource from the cache
resContent = plasmaHTCache.getResourceContentStream(url);
+ responseHeader = plasmaHTCache.loadResponseHeader(url);
if (resContent != null) {
// if the content was found
resContentLength = plasmaHTCache.getResourceContentLength(url);
@@ -285,13 +285,12 @@ public class plasmaSnippetCache {
// if not found try to download it
// download resource using the crawler and keep resource in memory if possible
- final httpdProxyCacheEntry entry = plasmaSwitchboard.getSwitchboard().crawlQueues.loadResourceFromWeb(url, timeout, true, true, reindexing);
+ final indexDocumentMetadata entry = plasmaSwitchboard.getSwitchboard().crawlQueues.loadResourceFromWeb(url, timeout, true, true, reindexing);
// getting resource metadata (e.g. the http headers for http resources)
if (entry != null) {
// place entry on crawl queue
plasmaHTCache.push(entry);
- resInfo = entry.getDocumentInfo();
// read resource body (if it is there)
final byte []resourceArray = entry.cacheArray();
@@ -321,7 +320,7 @@ public class plasmaSnippetCache {
* =========================================================================== */
plasmaParserDocument document = null;
try {
- document = parseDocument(url, resContentLength, resContent, resInfo);
+ document = parseDocument(url, resContentLength, resContent, responseHeader);
} catch (final ParserException e) {
return new TextSnippet(url, null, ERROR_PARSER_FAILED, queryhashes, e.getMessage()); // cannot be parsed
} finally {
@@ -385,10 +384,11 @@ public class plasmaSnippetCache {
// load resource
long resContentLength = 0;
InputStream resContent = null;
- IResourceInfo resInfo = null;
+ httpResponseHeader responseHeader = null;
try {
// trying to load the resource from the cache
resContent = plasmaHTCache.getResourceContentStream(url);
+ responseHeader = plasmaHTCache.loadResponseHeader(url);
if (resContent != null) {
// if the content was found
resContentLength = plasmaHTCache.getResourceContentLength(url);
@@ -396,11 +396,10 @@ public class plasmaSnippetCache {
// if not found try to download it
// download resource using the crawler and keep resource in memory if possible
- final httpdProxyCacheEntry entry = plasmaSwitchboard.getSwitchboard().crawlQueues.loadResourceFromWeb(url, timeout, true, forText, global);
+ final indexDocumentMetadata entry = plasmaSwitchboard.getSwitchboard().crawlQueues.loadResourceFromWeb(url, timeout, true, forText, global);
// getting resource metadata (e.g. the http headers for http resources)
if (entry != null) {
- resInfo = entry.getDocumentInfo();
// read resource body (if it is there)
final byte[] resourceArray = entry.cacheArray();
@@ -430,7 +429,7 @@ public class plasmaSnippetCache {
// parse resource
plasmaParserDocument document = null;
try {
- document = parseDocument(url, resContentLength, resContent, resInfo);
+ document = parseDocument(url, resContentLength, resContent, responseHeader);
} catch (final ParserException e) {
serverLog.logFine("snippet fetch", "parser error " + e.getMessage() + " for url " + url);
return null;
@@ -768,36 +767,35 @@ public class plasmaSnippetCache {
* @return the extracted data
* @throws ParserException
*/
- public static plasmaParserDocument parseDocument(final yacyURL url, final long contentLength, final InputStream resourceStream, IResourceInfo docInfo) throws ParserException {
+ public static plasmaParserDocument parseDocument(final yacyURL url, final long contentLength, final InputStream resourceStream, httpResponseHeader responseHeader) throws ParserException {
try {
if (resourceStream == null) return null;
// STEP 1: if no resource metadata is available, try to load it from cache
- if (docInfo == null) {
+ if (responseHeader == null) {
// try to get the header from the htcache directory
try {
- docInfo = plasmaHTCache.loadResourceInfo(url);
+ responseHeader = plasmaHTCache.loadResponseHeader(url);
} catch (final Exception e) {
// ignore this. resource info loading failed
}
}
// STEP 2: if the metadata is still null try to download it from web
- if ((docInfo == null) && (url.getProtocol().startsWith("http"))) {
+ if ((responseHeader == null) && (url.getProtocol().startsWith("http"))) {
// TODO: we need a better solution here
// e.g. encapsulate this in the crawlLoader class
// getting URL mimeType
try {
- final httpHeader header = HttpClient.whead(url.toString());
- docInfo = plasmaHTCache.getResourceInfoFactory().buildResourceInfoObj(url, header);
+ responseHeader = HttpClient.whead(url.toString());
} catch (final Exception e) {
// ingore this. http header download failed
}
}
// STEP 3: if the metadata is still null try to guess the mimeType of the resource
- if (docInfo == null) {
+ if (responseHeader == null) {
final String filename = plasmaHTCache.getCachePath(url).getName();
final int p = filename.lastIndexOf('.');
if ( // if no extension is available
@@ -820,8 +818,8 @@ public class plasmaSnippetCache {
}
return null;
}
- if (plasmaParser.supportedMimeTypesContains(docInfo.getMimeType())) {
- return parser.parseSource(url, docInfo.getMimeType(), docInfo.getCharacterEncoding(), contentLength, resourceStream);
+ if (plasmaParser.supportedMimeTypesContains(responseHeader.mime())) {
+ return parser.parseSource(url, responseHeader.mime(), responseHeader.getCharacterEncoding(), contentLength, resourceStream);
}
return null;
} catch (final InterruptedException e) {
@@ -854,7 +852,7 @@ public class plasmaSnippetCache {
// if the content is not available in cache try to download it from web
// try to download the resource using a crawler
- final httpdProxyCacheEntry entry = plasmaSwitchboard.getSwitchboard().crawlQueues.loadResourceFromWeb(url, (socketTimeout < 0) ? -1 : socketTimeout, true, forText, reindexing);
+ final indexDocumentMetadata entry = plasmaSwitchboard.getSwitchboard().crawlQueues.loadResourceFromWeb(url, (socketTimeout < 0) ? -1 : socketTimeout, true, forText, reindexing);
if (entry == null) return null; // not found in web
// read resource body (if it is there)
diff --git a/source/de/anomic/plasma/plasmaSwitchboard.java b/source/de/anomic/plasma/plasmaSwitchboard.java
index 832069b46..894f2007e 100644
--- a/source/de/anomic/plasma/plasmaSwitchboard.java
+++ b/source/de/anomic/plasma/plasmaSwitchboard.java
@@ -133,11 +133,12 @@ import de.anomic.data.wikiBoard;
import de.anomic.data.wiki.wikiParser;
import de.anomic.http.HttpClient;
import de.anomic.http.JakartaCommonsHttpClient;
-import de.anomic.http.httpHeader;
import de.anomic.http.httpRemoteProxyConfig;
+import de.anomic.http.httpRequestHeader;
+import de.anomic.http.httpResponseHeader;
import de.anomic.http.httpd;
-import de.anomic.http.httpdProxyCacheEntry;
import de.anomic.http.httpdRobotsTxtConfig;
+import de.anomic.index.indexDocumentMetadata;
import de.anomic.index.indexReferenceBlacklist;
import de.anomic.index.indexURLReference;
import de.anomic.kelondro.kelondroCache;
@@ -968,7 +969,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.
return this.webIndex.cleanProfiles();
}
- public boolean htEntryStoreProcess(final httpdProxyCacheEntry entry) {
+ public boolean htEntryStoreProcess(final indexDocumentMetadata entry) {
if (entry == null) return false;
@@ -1052,7 +1053,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.
));
} else {
if (!entry.profile().storeHTCache() && entry.cacheFile().exists()) {
- plasmaHTCache.deleteURLfromCache(entry.url());
+ plasmaHTCache.deleteURLfromCache(entry.url(), false);
}
}
}
@@ -1787,16 +1788,16 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.
}
}
- public int adminAuthenticated(final httpHeader header) {
+ public int adminAuthenticated(final httpRequestHeader requestHeader) {
// authorization for localhost, only if flag is set to grant localhost access as admin
- final String clientIP = (String) header.get(httpHeader.CONNECTION_PROP_CLIENTIP, "");
- final String refererHost = header.refererHost();
+ final String clientIP = (String) requestHeader.get(httpRequestHeader.CONNECTION_PROP_CLIENTIP, "");
+ final String refererHost = requestHeader.refererHost();
final boolean accessFromLocalhost = serverCore.isLocalhost(clientIP) && (refererHost.length() == 0 || serverCore.isLocalhost(refererHost));
if (getConfigBool("adminAccountForLocalhost", false) && accessFromLocalhost) return 3; // soft-authenticated for localhost
// get the authorization string from the header
- final String authorization = ((String) header.get(httpHeader.AUTHORIZATION, "xxxxxx")).trim().substring(6);
+ final String authorization = ((String) requestHeader.get(httpRequestHeader.AUTHORIZATION, "xxxxxx")).trim().substring(6);
// security check against too long authorization strings
if (authorization.length() > 256) return 0;
@@ -1806,13 +1807,13 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.
if (accessFromLocalhost && (adminAccountBase64MD5.equals(authorization))) return 3; // soft-authenticated for localhost
// authorization by hit in userDB
- if (userDB.hasAdminRight((String) header.get(httpHeader.AUTHORIZATION, "xxxxxx"), ((String) header.get(httpHeader.CONNECTION_PROP_CLIENTIP, "")), header.getHeaderCookies())) return 4; //return, because 4=max
+ if (userDB.hasAdminRight((String) requestHeader.get(httpRequestHeader.AUTHORIZATION, "xxxxxx"), ((String) requestHeader.get(httpRequestHeader.CONNECTION_PROP_CLIENTIP, "")), requestHeader.getHeaderCookies())) return 4; //return, because 4=max
// authorization with admin keyword in configuration
return httpd.staticAdminAuthenticated(authorization, this);
}
- public boolean verifyAuthentication(final httpHeader header, final boolean strict) {
+ public boolean verifyAuthentication(final httpRequestHeader header, final boolean strict) {
// handle access rights
switch (adminAuthenticated(header)) {
case 0: // wrong password given
@@ -2147,14 +2148,14 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.
public void loadSeedLists() {
// uses the superseed to initialize the database with known seeds
- yacySeed ys;
- String seedListFileURL;
- yacyURL url;
- ArrayList<String> seedList;
- Iterator<String> enu;
- int lc;
- final int sc = webIndex.seedDB.sizeConnected();
- httpHeader header;
+ yacySeed ys;
+ String seedListFileURL;
+ yacyURL url;
+ ArrayList<String> seedList;
+ Iterator<String> enu;
+ int lc;
+ final int sc = webIndex.seedDB.sizeConnected();
+ httpResponseHeader header;
yacyCore.log.logInfo("BOOTSTRAP: " + sc + " seeds known from previous run");
@@ -2171,10 +2172,10 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.
) {
// load the seed list
try {
- final httpHeader reqHeader = new httpHeader();
- reqHeader.put(httpHeader.PRAGMA, "no-cache");
- reqHeader.put(httpHeader.CACHE_CONTROL, "no-cache");
- reqHeader.put(httpHeader.USER_AGENT, HTTPLoader.yacyUserAgent);
+ final httpRequestHeader reqHeader = new httpRequestHeader();
+ reqHeader.put(httpRequestHeader.PRAGMA, "no-cache");
+ reqHeader.put(httpRequestHeader.CACHE_CONTROL, "no-cache");
+ reqHeader.put(httpRequestHeader.USER_AGENT, HTTPLoader.yacyUserAgent);
url = new yacyURL(seedListFileURL, null);
final long start = System.currentTimeMillis();
@@ -2257,8 +2258,8 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.
public static Map<String, String> loadHashMap(final yacyURL url) {
try {
// sending request
- final httpHeader reqHeader = new httpHeader();
- reqHeader.put(httpHeader.USER_AGENT, HTTPLoader.yacyUserAgent);
+ final httpRequestHeader reqHeader = new httpRequestHeader();
+ reqHeader.put(httpRequestHeader.USER_AGENT, HTTPLoader.yacyUserAgent);
final HashMap<String, String> result = nxTools.table(HttpClient.wget(url.toString(), reqHeader, 10000), "UTF-8");
if (result == null) return new HashMap<String, String>();
return result;
diff --git a/source/de/anomic/server/serverDate.java b/source/de/anomic/server/serverDate.java
index ebe9a5082..d029a6e18 100644
--- a/source/de/anomic/server/serverDate.java
+++ b/source/de/anomic/server/serverDate.java
@@ -72,7 +72,9 @@ public final class serverDate {
private static final SimpleDateFormat FORMAT_ISO8601 = new SimpleDateFormat(PATTERN_ISO8601);
/** Date formatter/parser for standard compliant HTTP header dates (RFC 1123) */
- private static final SimpleDateFormat FORMAT_RFC1123 = new SimpleDateFormat(PATTERN_RFC1123, Locale.US);
+ private static final SimpleDateFormat FORMAT_RFC1123 = new SimpleDateFormat(PATTERN_RFC1123, Locale.US);
+
+ private static final SimpleDateFormat FORMAT_RFC1036 = new SimpleDateFormat(PATTERN_RFC1036, Locale.US);
/**
* RFC 2616 requires that HTTP clients are able to parse all 3 different
@@ -82,7 +84,7 @@ public final class serverDate {
// RFC 1123/822 (Standard) "Mon, 12 Nov 2007 10:11:12 GMT"
FORMAT_RFC1123,
// RFC 1036/850 (old) "Monday, 12-Nov-07 10:11:12 GMT"
- new SimpleDateFormat(PATTERN_RFC1036, Locale.US),
+ FORMAT_RFC1036,
// ANSI C asctime() "Mon Nov 12 10:11:12 2007"
new SimpleDateFormat(PATTERN_ANSIC, Locale.US),
};
diff --git a/source/de/anomic/server/servletProperties.java b/source/de/anomic/server/servletProperties.java
index afcf684d5..62ea97f5d 100644
--- a/source/de/anomic/server/servletProperties.java
+++ b/source/de/anomic/server/servletProperties.java
@@ -21,7 +21,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 US
package de.anomic.server;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpResponseHeader;
public class servletProperties extends serverObjects {
@@ -37,7 +37,7 @@ public class servletProperties extends serverObjects {
private String prefix="";
- private httpHeader outgoingHeader;
+ private httpResponseHeader outgoingHeader;
public servletProperties(){
super();
@@ -47,13 +47,13 @@ public class servletProperties extends serverObjects {
super(so);
}
- public void setOutgoingHeader(final httpHeader outgoingHeader) {
+ public void setOutgoingHeader(final httpResponseHeader outgoingHeader) {
this.outgoingHeader = outgoingHeader;
}
- public httpHeader getOutgoingHeader() {
+ public httpResponseHeader getOutgoingHeader() {
if(outgoingHeader == null)
- return new httpHeader();
+ return new httpResponseHeader();
return outgoingHeader;
}
diff --git a/source/de/anomic/tools/loaderThreads.java b/source/de/anomic/tools/loaderThreads.java
index 29122f056..ce2b86ef1 100644
--- a/source/de/anomic/tools/loaderThreads.java
+++ b/source/de/anomic/tools/loaderThreads.java
@@ -26,8 +26,8 @@ import java.util.Hashtable;
import de.anomic.crawler.HTTPLoader;
import de.anomic.http.HttpClient;
-import de.anomic.http.httpHeader;
import de.anomic.http.httpRemoteProxyConfig;
+import de.anomic.http.httpRequestHeader;
import de.anomic.yacy.yacyURL;
public class loaderThreads {
@@ -122,8 +122,8 @@ public class loaderThreads {
public void run() {
try {
- final httpHeader reqHeader = new httpHeader();
- reqHeader.put(httpHeader.USER_AGENT, HTTPLoader.crawlerUserAgent);
+ final httpRequestHeader reqHeader = new httpRequestHeader();
+ reqHeader.put(httpRequestHeader.USER_AGENT, HTTPLoader.crawlerUserAgent);
page = HttpClient.wget(url.toString(), reqHeader, timeout);
loaded = true;
process.feed(page);
diff --git a/source/de/anomic/urlRedirector/urlRedirectord.java b/source/de/anomic/urlRedirector/urlRedirectord.java
index f67449efc..9f0d021b0 100644
--- a/source/de/anomic/urlRedirector/urlRedirectord.java
+++ b/source/de/anomic/urlRedirector/urlRedirectord.java
@@ -10,7 +10,7 @@ import java.util.Date;
import de.anomic.crawler.CrawlProfile;
import de.anomic.data.userDB;
import de.anomic.http.HttpClient;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpResponseHeader;
import de.anomic.plasma.plasmaParser;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverCore;
@@ -181,7 +181,7 @@ public class urlRedirectord implements serverHandler, Cloneable {
final yacyURL reqURL = new yacyURL(this.nextURL, null);
// getting URL mimeType
- final httpHeader header = HttpClient.whead(reqURL.toString());
+ final httpResponseHeader header = HttpClient.whead(reqURL.toString());
if (plasmaParser.supportedContent(
plasmaParser.PARSER_MODE_URLREDIRECTOR,
diff --git a/source/de/anomic/yacy/yacyClient.java b/source/de/anomic/yacy/yacyClient.java
index 10d2e9b3b..821e6b49b 100644
--- a/source/de/anomic/yacy/yacyClient.java
+++ b/source/de/anomic/yacy/yacyClient.java
@@ -65,8 +65,8 @@ import de.anomic.http.DefaultCharsetStringPart;
import de.anomic.http.HttpClient;
import de.anomic.http.JakartaCommonsHttpClient;
import de.anomic.http.JakartaCommonsHttpResponse;
-import de.anomic.http.httpHeader;
import de.anomic.http.httpRemoteProxyConfig;
+import de.anomic.http.httpRequestHeader;
import de.anomic.index.indexContainer;
import de.anomic.index.indexRWIEntry;
import de.anomic.index.indexRWIRowEntry;
@@ -267,9 +267,9 @@ public final class yacyClient {
* @throws IOException
*/
private static byte[] wput(final String url, final String vhost, final List<Part> post, final int timeout, final boolean gzipBody) throws IOException {
- final httpHeader header = new httpHeader();
- header.put(httpHeader.USER_AGENT, HTTPLoader.yacyUserAgent);
- header.put(httpHeader.HOST, vhost);
+ final httpRequestHeader header = new httpRequestHeader();
+ header.put(httpRequestHeader.USER_AGENT, HTTPLoader.yacyUserAgent);
+ header.put(httpRequestHeader.HOST, vhost);
final JakartaCommonsHttpClient client = new JakartaCommonsHttpClient(timeout, header);
client.setProxy(proxyConfig());
@@ -1071,8 +1071,8 @@ public final class yacyClient {
final String wordhashe = indexWord.word2hash("test");
//System.out.println("permission=" + permissionMessage(args[1]));
- final httpHeader reqHeader = new httpHeader();
- reqHeader.put(httpHeader.USER_AGENT, HTTPLoader.crawlerUserAgent);
+ final httpRequestHeader reqHeader = new httpRequestHeader();
+ reqHeader.put(httpRequestHeader.USER_AGENT, HTTPLoader.crawlerUserAgent);
final byte[] content = HttpClient.wget(
"http://" + target.getPublicAddress() + "/yacy/search.html" +
"?myseed=" + sb.webIndex.seedDB.mySeed().genSeedStr(null) +
diff --git a/source/de/anomic/yacy/yacySeedDB.java b/source/de/anomic/yacy/yacySeedDB.java
index 9eae70111..c91fd84af 100644
--- a/source/de/anomic/yacy/yacySeedDB.java
+++ b/source/de/anomic/yacy/yacySeedDB.java
@@ -44,7 +44,7 @@ import java.util.TreeMap;
import de.anomic.crawler.HTTPLoader;
import de.anomic.http.JakartaCommonsHttpClient;
import de.anomic.http.JakartaCommonsHttpResponse;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.http.httpd;
import de.anomic.http.httpdAlternativeDomainNames;
import de.anomic.kelondro.kelondroBLOBTree;
@@ -843,10 +843,10 @@ public final class yacySeedDB implements httpdAlternativeDomainNames {
private ArrayList<String> downloadSeedFile(final yacyURL seedURL) throws IOException {
// Configure http headers
- final httpHeader reqHeader = new httpHeader();
- reqHeader.put(httpHeader.PRAGMA, "no-cache");
- reqHeader.put(httpHeader.CACHE_CONTROL, "no-cache"); // httpc uses HTTP/1.0 is this necessary?
- reqHeader.put(httpHeader.USER_AGENT, HTTPLoader.yacyUserAgent);
+ final httpRequestHeader reqHeader = new httpRequestHeader();
+ reqHeader.put(httpRequestHeader.PRAGMA, "no-cache");
+ reqHeader.put(httpRequestHeader.CACHE_CONTROL, "no-cache"); // httpc uses HTTP/1.0 is this necessary?
+ reqHeader.put(httpRequestHeader.USER_AGENT, HTTPLoader.yacyUserAgent);
// init http-client
final JakartaCommonsHttpClient client = new JakartaCommonsHttpClient(10000, reqHeader);
diff --git a/source/de/anomic/yacy/yacyVersion.java b/source/de/anomic/yacy/yacyVersion.java
index 4a278e804..15876c1e7 100644
--- a/source/de/anomic/yacy/yacyVersion.java
+++ b/source/de/anomic/yacy/yacyVersion.java
@@ -46,7 +46,8 @@ import de.anomic.crawler.HTTPLoader;
import de.anomic.htmlFilter.htmlFilterContentScraper;
import de.anomic.http.JakartaCommonsHttpClient;
import de.anomic.http.JakartaCommonsHttpResponse;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpResponseHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverCore;
import de.anomic.server.serverFileUtils;
@@ -338,8 +339,8 @@ public final class yacyVersion implements Comparator<yacyVersion>, Comparable<ya
final File storagePath = plasmaSwitchboard.getSwitchboard().releasePath;
// load file
File download = null;
- final httpHeader header = new httpHeader();
- header.put(httpHeader.USER_AGENT, HTTPLoader.yacyUserAgent);
+ final httpRequestHeader header = new httpRequestHeader();
+ header.put(httpResponseHeader.USER_AGENT, HTTPLoader.yacyUserAgent);
final JakartaCommonsHttpClient client = new JakartaCommonsHttpClient(120000, header);
JakartaCommonsHttpResponse res = null;
final String name = release.url.getFileName();
diff --git a/source/de/anomic/ymage/ymageOSM.java b/source/de/anomic/ymage/ymageOSM.java
index d5195a3d9..d5f6888ae 100644
--- a/source/de/anomic/ymage/ymageOSM.java
+++ b/source/de/anomic/ymage/ymageOSM.java
@@ -35,7 +35,7 @@ import java.net.MalformedURLException;
import javax.imageio.ImageIO;
-import de.anomic.http.httpdProxyCacheEntry;
+import de.anomic.index.indexDocumentMetadata;
import de.anomic.plasma.plasmaHTCache;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.yacy.yacyURL;
@@ -79,7 +79,7 @@ public class ymageOSM {
InputStream tileStream = plasmaHTCache.getResourceContentStream(tileURL);
if (tileStream == null) {
// download resource using the crawler and keep resource in memory if possible
- final httpdProxyCacheEntry entry = plasmaSwitchboard.getSwitchboard().crawlQueues.loadResourceFromWeb(tileURL, 20000, true, false, false);
+ final indexDocumentMetadata entry = plasmaSwitchboard.getSwitchboard().crawlQueues.loadResourceFromWeb(tileURL, 20000, true, false, false);
if ((entry == null) || (entry.cacheArray() == null)) return null;
tileStream = new ByteArrayInputStream(entry.cacheArray());
}
diff --git a/source/yacy.java b/source/yacy.java
index 45256036a..9dda5efd9 100644
--- a/source/yacy.java
+++ b/source/yacy.java
@@ -51,7 +51,7 @@ import de.anomic.data.translator;
import de.anomic.http.HttpClient;
import de.anomic.http.JakartaCommonsHttpClient;
import de.anomic.http.JakartaCommonsHttpResponse;
-import de.anomic.http.httpHeader;
+import de.anomic.http.httpRequestHeader;
import de.anomic.http.httpd;
import de.anomic.index.indexContainer;
import de.anomic.index.indexRWIEntry;
@@ -566,8 +566,8 @@ public final class yacy {
if (encodedPassword == null) encodedPassword = ""; // not defined
// send 'wget' to web interface
- final httpHeader requestHeader = new httpHeader();
- requestHeader.put(httpHeader.AUTHORIZATION, "realm=" + encodedPassword); // for http-authentify
+ final httpRequestHeader requestHeader = new httpRequestHeader();
+ requestHeader.put(httpRequestHeader.AUTHORIZATION, "realm=" + encodedPassword); // for http-authentify
final JakartaCommonsHttpClient con = new JakartaCommonsHttpClient(10000, requestHeader);
JakartaCommonsHttpResponse res = null;
try {