Author: remy.maucherat(a)jboss.com
Date: 2013-02-20 10:52:42 -0500 (Wed, 20 Feb 2013)
New Revision: 2169
Modified:
branches/7.2.x/src/main/java/org/apache/tomcat/util/http/CookieSupport.java
branches/7.2.x/src/main/java/org/apache/tomcat/util/http/Cookies.java
branches/7.2.x/webapps/docs/changelog.xml
Log:
JBWEB-266
Add an option to preserve the cookie header during processing. Although not a very good
idea,
it is allowed to "start over" cookie processing from the original header value.
Also useful for
debugging, maybe.
Modified: branches/7.2.x/src/main/java/org/apache/tomcat/util/http/CookieSupport.java
===================================================================
--- branches/7.2.x/src/main/java/org/apache/tomcat/util/http/CookieSupport.java 2013-02-14
23:27:11 UTC (rev 2168)
+++ branches/7.2.x/src/main/java/org/apache/tomcat/util/http/CookieSupport.java 2013-02-20
15:52:42 UTC (rev 2169)
@@ -62,6 +62,12 @@
public static final boolean FWD_SLASH_IS_SEPARATOR;
/**
+ * If set to true, the cookie header will be preserved. In most cases
+ * except debugging, this is not useful.
+ */
+ public static final boolean PRESERVE_COOKIE_HEADER;
+
+ /**
* The list of separators that apply to version 0 cookies. To quote the
* spec, these are comma, semi-colon and white-space. The HTTP spec
* definition of linear white space is [CRLF] 1*( SP | HT )
@@ -94,6 +100,10 @@
"org.apache.tomcat.util.http.ServerCookie.FWD_SLASH_IS_SEPARATOR",
"false")).booleanValue();
+ PRESERVE_COOKIE_HEADER = Boolean.valueOf(System.getProperty(
+
"org.apache.tomcat.util.http.ServerCookie.PRESERVE_COOKIE_HEADER",
+ "false")).booleanValue();
+
String alwaysAddExpires = System.getProperty(
"org.apache.tomcat.util.http.ServerCookie.ALWAYS_ADD_EXPIRES");
if (alwaysAddExpires == null) {
Modified: branches/7.2.x/src/main/java/org/apache/tomcat/util/http/Cookies.java
===================================================================
--- branches/7.2.x/src/main/java/org/apache/tomcat/util/http/Cookies.java 2013-02-14
23:27:11 UTC (rev 2168)
+++ branches/7.2.x/src/main/java/org/apache/tomcat/util/http/Cookies.java 2013-02-20
15:52:42 UTC (rev 2169)
@@ -147,9 +147,18 @@
cookieValue.toBytes();
}
ByteChunk bc=cookieValue.getByteChunk();
- processCookieHeader( bc.getBytes(),
- bc.getOffset(),
- bc.getLength());
+ if (CookieSupport.PRESERVE_COOKIE_HEADER) {
+ int len = bc.getLength();
+ if (len > 0) {
+ byte[] buf = new byte[len];
+ System.arraycopy(bc.getBytes(), bc.getOffset(), buf, 0, len);
+ processCookieHeader(buf, 0, len);
+ }
+ } else {
+ processCookieHeader( bc.getBytes(),
+ bc.getOffset(),
+ bc.getLength());
+ }
pos++;// search from the next position
}
}
Modified: branches/7.2.x/webapps/docs/changelog.xml
===================================================================
--- branches/7.2.x/webapps/docs/changelog.xml 2013-02-14 23:27:11 UTC (rev 2168)
+++ branches/7.2.x/webapps/docs/changelog.xml 2013-02-20 15:52:42 UTC (rev 2169)
@@ -24,6 +24,13 @@
</fix>
</changelog>
</subsection>
+ <subsection name="Coyote">
+ <changelog>
+ <fix>
+ <jira>266</jira>: Add an option to preserve the cookie header during
processing. (remm)
+ </fix>
+ </changelog>
+ </subsection>
</section>
<section name="JBoss Web 7.2.0.Final (remm)">
Show replies by date