Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
fix and prevent exception on missing required cookie name skip cookie creation if name is empty.
reger7bf2bcf504cc
diff --git a/htroot/CookieTest_p.java b/htroot/CookieTest_p.javaindex 801493603..5d445caa5 100644--- a/htroot/CookieTest_p.java+++ b/htroot/CookieTest_p.java@@ -61,7 +61,7 @@ public class CookieTest_p {final String cookies[] = CommonPattern.SEMICOLON.split(e.getValue());for (final String cookie : cookies) {final String nameValue[] = cookie.split("=");- outgoingHeader.setCookie(nameValue[0].trim(), nameValue.length > 1 ? (nameValue[1].trim()) : "", 0);+ outgoingHeader.setCookie(nameValue[0].trim(), nameValue.length > 1 ? (nameValue[1].trim()) : "");}}}diff --git a/source/net/yacy/cora/protocol/ResponseHeader.java b/source/net/yacy/cora/protocol/ResponseHeader.javaindex f5112ac6c..2c3d44c49 100644--- a/source/net/yacy/cora/protocol/ResponseHeader.java+++ b/source/net/yacy/cora/protocol/ResponseHeader.java@@ -48,7 +48,7 @@ public class ResponseHeader extends HeaderFramework {super();this.put(HeaderFramework.STATUS_CODE, Integer.toString(statusCode));for (final Header h : headers) {- add(h.getName(), h.getValue());+ add(h.getName(), h.getValue());}}@@ -155,28 +155,17 @@ public class ResponseHeader extends HeaderFramework {* For example semicolon should be not in any of the values* However an exception in this case would be an overhead IMHO.*/- if (this.cookieStore == null) this.cookieStore = new ArrayList<Cookie>();- Cookie c = new Cookie (name, value);- if (maxage != null) c.setMaxAge(maxage);- if (path != null) c.setPath(path);- if (domain != null) c.setDomain(domain);- if (secure) c.setSecure(secure);- this.cookieStore.add(c);- }- /**- * Sets Cookie on the client machine.- *- * @param name Cookie name- * @param value Cookie value- * @param maxage time to live in seconds, none negative number, according to https://tools.ietf.org/html/rfc2109, 0=discard in https://tools.ietf.org/html/rfc2965- *- * Note: this cookie will be sent over each connection independent if it is safe connection or not.- * @see further documentation: <a href="http://docs.sun.com/source/816-6408-10/cookies.htm">docs.sun.com</a>- */- public void setCookie(final String name, final String value, final Integer maxage)- {- setCookie( name, value, maxage, null, null, false);+ if (!name.isEmpty()) {+ if (this.cookieStore == null) this.cookieStore = new ArrayList<Cookie>();+ Cookie c = new Cookie (name, value);+ if (maxage != null) c.setMaxAge(maxage);+ if (path != null) c.setPath(path);+ if (domain != null) c.setDomain(domain);+ if (secure) c.setSecure(secure);+ this.cookieStore.add(c);+ }}+/*** Sets Cookie on the client machine.*