Skip to content

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

fix legacy getHeaderCookies to work with cookies from original HttpServletRequest, by moving to RequestHeader.

reger60ba5c117c4b
diff --git a/source/net/yacy/cora/protocol/HeaderFramework.java b/source/net/yacy/cora/protocol/HeaderFramework.java
index 27ae39871..f9a41136a 100644
--- a/source/net/yacy/cora/protocol/HeaderFramework.java
+++ b/source/net/yacy/cora/protocol/HeaderFramework.java
@@ -744,25 +744,6 @@ public class HeaderFramework extends TreeMap<String, String> implements Map<Stri
setCookie( name, value, null, null, null, false);
}
- /**
- * Gets the header entry "Cookie"
- *
- * @return String with cookies separated by ';'
- */
- public String getHeaderCookies(){
- final Iterator<Map.Entry<String, String>> it = entrySet().iterator();
- while(it.hasNext())
- {
- final Map.Entry<String, String> e = it.next();
- //System.out.println(""+e.getKey()+" : "+e.getValue());
- if(e.getKey().equals("Cookie"))
- {
- return e.getValue();
- }
- }
- return "";
- }
-
public Vector<Entry> getAdditionalHeaderProperties() {
return this.headerProps;
}
diff --git a/source/net/yacy/cora/protocol/RequestHeader.java b/source/net/yacy/cora/protocol/RequestHeader.java
index ffd0c7f6d..ab65ac611 100644
--- a/source/net/yacy/cora/protocol/RequestHeader.java
+++ b/source/net/yacy/cora/protocol/RequestHeader.java
@@ -146,6 +146,21 @@ public class RequestHeader extends HeaderFramework implements HttpServletRequest
return false;
}
+ /**
+ * Gets the header entry "Cookie" as on string containing all cookies
+ *
+ * @return String with cookies separated by ';'
+ * @see getCookies()
+ */
+ public String getHeaderCookies() { // TODO: harmonize with standard getCookies
+ String cookiestring = this.get(COOKIE); // get from legacy or HttpServletRequest
+ if (cookiestring == null) {
+ return "";
+ } else {
+ return cookiestring;
+ }
+ }
+
// implementation of HttpServletRequest procedures
// the general approach is to prefer values in the YaCy legacy RequestHeader.map and if no value exists
// to use the httpservletrequest. This approach is used, because legacy requestheader allows to add or