|
|
|
@ -104,6 +104,9 @@ public class HeaderFramework extends TreeMap<String, String> implements Map<Stri
|
|
|
|
|
public static final String VIA = "Via";
|
|
|
|
|
|
|
|
|
|
public static final String X_FORWARDED_FOR = "X-Forwarded-For";
|
|
|
|
|
public static final String X_ROBOTS_TAG = "X-Robots-Tag"; // see http://googleblog.blogspot.com/2007/07/robots-exclusion-protocol-now-with-even.html
|
|
|
|
|
public static final String X_ROBOTS = "X-Robots";
|
|
|
|
|
|
|
|
|
|
public static final String X_YACY_INDEX_CONTROL = "X-YACY-Index-Control";
|
|
|
|
|
//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";
|
|
|
|
@ -235,7 +238,7 @@ public class HeaderFramework extends TreeMap<String, String> implements Map<Stri
|
|
|
|
|
this.reverseMappingCache = reverseMappingCache;
|
|
|
|
|
|
|
|
|
|
// load with data
|
|
|
|
|
if (othermap != null) this.putAll(othermap);
|
|
|
|
|
if (othermap != null) putAll(othermap);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Date formatter/parser for standard compliant HTTP header dates (RFC 1123) */
|
|
|
|
@ -272,7 +275,7 @@ public class HeaderFramework extends TreeMap<String, String> implements Map<Stri
|
|
|
|
|
return lastRFC1123string;
|
|
|
|
|
}
|
|
|
|
|
synchronized (FORMAT_RFC1123) {
|
|
|
|
|
String s = FORMAT_RFC1123.format(date);
|
|
|
|
|
final String s = FORMAT_RFC1123.format(date);
|
|
|
|
|
lastRFC1123long = date.getTime();
|
|
|
|
|
lastRFC1123string = s;
|
|
|
|
|
return s;
|
|
|
|
@ -286,7 +289,7 @@ public class HeaderFramework extends TreeMap<String, String> implements Map<Stri
|
|
|
|
|
// the year value starting with 1970
|
|
|
|
|
CAL_GMT.setTimeInMillis(0);
|
|
|
|
|
|
|
|
|
|
for (SimpleDateFormat format: FORMATS_HTTP) {
|
|
|
|
|
for (final SimpleDateFormat format: FORMATS_HTTP) {
|
|
|
|
|
format.setTimeZone(TZ_GMT);
|
|
|
|
|
format.set2DigitYearStart(CAL_GMT.getTime());
|
|
|
|
|
}
|
|
|
|
@ -300,7 +303,7 @@ public class HeaderFramework extends TreeMap<String, String> implements Map<Stri
|
|
|
|
|
public static Date parseHTTPDate(String s) {
|
|
|
|
|
s = s.trim();
|
|
|
|
|
if (s == null || s.length() < 9) return null;
|
|
|
|
|
for (SimpleDateFormat format: FORMATS_HTTP) synchronized (format) {
|
|
|
|
|
for (final SimpleDateFormat format: FORMATS_HTTP) synchronized (format) {
|
|
|
|
|
try { return format.parse(s); } catch (final ParseException e) {}
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
@ -311,18 +314,18 @@ public class HeaderFramework extends TreeMap<String, String> implements Map<Stri
|
|
|
|
|
public String put(final String key, final String value) {
|
|
|
|
|
final String upperK = key.toUpperCase();
|
|
|
|
|
|
|
|
|
|
if (reverseMappingCache == null) {
|
|
|
|
|
if (this.reverseMappingCache == null) {
|
|
|
|
|
return super.put(key, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (reverseMappingCache.containsKey(upperK)) {
|
|
|
|
|
if (this.reverseMappingCache.containsKey(upperK)) {
|
|
|
|
|
// we put in the value using the reverse mapping
|
|
|
|
|
return super.put(reverseMappingCache.get(upperK), value);
|
|
|
|
|
return super.put(this.reverseMappingCache.get(upperK), value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// we put in without a cached key and store the key afterwards
|
|
|
|
|
final String r = super.put(key, value);
|
|
|
|
|
reverseMappingCache.put(upperK, key);
|
|
|
|
|
this.reverseMappingCache.put(upperK, key);
|
|
|
|
|
return r;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -336,7 +339,7 @@ public class HeaderFramework extends TreeMap<String, String> implements Map<Stri
|
|
|
|
|
public int keyCount(final String key) {
|
|
|
|
|
if (!(containsKey(key))) return 0;
|
|
|
|
|
int c = 1;
|
|
|
|
|
String h = "*" + key + "-";
|
|
|
|
|
final String h = "*" + key + "-";
|
|
|
|
|
while (containsKey(h + Integer.toString(c))) c++;
|
|
|
|
|
return c;
|
|
|
|
|
}
|
|
|
|
@ -366,7 +369,7 @@ public class HeaderFramework extends TreeMap<String, String> implements Map<Stri
|
|
|
|
|
FileOutputStream fos = null;
|
|
|
|
|
try {
|
|
|
|
|
fos = new FileOutputStream(f);
|
|
|
|
|
for (java.util.Map.Entry<String, String> entry: entrySet()) {
|
|
|
|
|
for (final java.util.Map.Entry<String, String> entry: entrySet()) {
|
|
|
|
|
fos.write(UTF8.getBytes(entry.getKey() + "=" + entry.getValue() + "\r\n"));
|
|
|
|
|
}
|
|
|
|
|
fos.flush();
|
|
|
|
@ -604,10 +607,10 @@ public class HeaderFramework extends TreeMap<String, String> implements Map<Stri
|
|
|
|
|
this.v = v;
|
|
|
|
|
}
|
|
|
|
|
public String getKey() {
|
|
|
|
|
return k;
|
|
|
|
|
return this.k;
|
|
|
|
|
}
|
|
|
|
|
public String getValue() {
|
|
|
|
|
return v;
|
|
|
|
|
return this.v;
|
|
|
|
|
}
|
|
|
|
|
public String setValue(final String v) {
|
|
|
|
|
final String r = this.v;
|
|
|
|
@ -639,7 +642,7 @@ public class HeaderFramework extends TreeMap<String, String> implements Map<Stri
|
|
|
|
|
if (path != null) cookieString += " path=" + path + ";";
|
|
|
|
|
if (domain != null) cookieString += " domain=" + domain + ";";
|
|
|
|
|
if (secure) cookieString += " secure;";
|
|
|
|
|
headerProps.add(new Entry("Set-Cookie", cookieString));
|
|
|
|
|
this.headerProps.add(new Entry("Set-Cookie", cookieString));
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Sets Cookie on the client machine.
|
|
|
|
@ -700,7 +703,7 @@ public class HeaderFramework extends TreeMap<String, String> implements Map<Stri
|
|
|
|
|
setCookie( name, value, null, null, null, false);
|
|
|
|
|
}
|
|
|
|
|
public String getHeaderCookies(){
|
|
|
|
|
final Iterator<Map.Entry<String, String>> it = this.entrySet().iterator();
|
|
|
|
|
final Iterator<Map.Entry<String, String>> it = entrySet().iterator();
|
|
|
|
|
while(it.hasNext())
|
|
|
|
|
{
|
|
|
|
|
final Map.Entry<String, String> e = it.next();
|
|
|
|
@ -714,15 +717,15 @@ public class HeaderFramework extends TreeMap<String, String> implements Map<Stri
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void addHeader(final String key, final String value) {
|
|
|
|
|
headerProps.add(new Entry(key, value));
|
|
|
|
|
this.headerProps.add(new Entry(key, value));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Vector<Entry> getAdditionalHeaderProperties() {
|
|
|
|
|
return headerProps;
|
|
|
|
|
return this.headerProps;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setAdditionalHeaderProperties(final Vector<Entry> mycookies){
|
|
|
|
|
headerProps=mycookies;
|
|
|
|
|
this.headerProps=mycookies;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|