Author: markt
Date: Thu Feb 7 12:36:12 2019
New Revision: 1853124
URL: http://svn.apache.org/viewvc?rev=1853124&view=rev
Log:
Refactor how cookies are transferred from the base request to a PushBuilder so
that they are accessible, and may be edited, via the standard PushBuilder
methods for working with HTTP headers.
The inability to manipulate cookies was highlighted by a failing Servlet 4 TCK
test
Modified:
tomcat/trunk/java/org/apache/catalina/core/ApplicationPushBuilder.java
tomcat/trunk/webapps/docs/changelog.xml
Modified: tomcat/trunk/java/org/apache/catalina/core/ApplicationPushBuilder.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/ApplicationPushBuilder.java?rev=1853124&r1=1853123&r2=1853124&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/ApplicationPushBuilder.java
(original)
+++ tomcat/trunk/java/org/apache/catalina/core/ApplicationPushBuilder.java Thu
Feb 7 12:36:12 2019
@@ -39,6 +39,7 @@ import org.apache.catalina.connector.Req
import org.apache.catalina.util.SessionConfig;
import org.apache.coyote.ActionCode;
import org.apache.tomcat.util.buf.HexUtils;
+import org.apache.tomcat.util.buf.MessageBytes;
import org.apache.tomcat.util.collections.CaseInsensitiveKeyMap;
import org.apache.tomcat.util.http.CookieProcessor;
import org.apache.tomcat.util.http.parser.HttpParser;
@@ -158,6 +159,10 @@ public class ApplicationPushBuilder impl
cookies.add(new Cookie(responseCookie.getName(),
responseCookie.getValue()));
}
}
+ List<String> cookieValues = new ArrayList<>(1);
+ cookieValues.add(generateCookieHeader(cookies,
+ catalinaRequest.getContext().getCookieProcessor()));
+ headers.put("cookie", cookieValues);
// Authentication
if (catalinaRequest.getPrincipal() != null) {
@@ -339,7 +344,14 @@ public class ApplicationPushBuilder impl
pushTarget.addPathParameter(sessionPathParameterName,
sessionId);
}
if (addSessionCookie) {
- cookies.add(new Cookie(sessionCookieName, sessionId));
+ String sessionCookieHeader = sessionCookieName + "=" +
sessionId;
+ MessageBytes mb =
pushTarget.getMimeHeaders().getValue("cookie");
+ if (mb == null) {
+ mb = pushTarget.getMimeHeaders().addValue("cookie");
+ mb.setString(sessionCookieHeader);
+ } else {
+ mb.setString(mb.getString() + ";" + sessionCookieHeader);
+ }
}
}
@@ -357,11 +369,6 @@ public class ApplicationPushBuilder impl
pushTarget.queryString().setString(pushQueryString + "&"
+queryString);
}
- // Cookies
- pushTarget.getMimeHeaders().addValue("cookie")
- .setString(generateCookieHeader(cookies,
- catalinaRequest.getContext().getCookieProcessor()));
-
// Authorization
if (userName != null) {
pushTarget.getRemoteUser().setString(userName);
Modified: tomcat/trunk/webapps/docs/changelog.xml
URL:
http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1853124&r1=1853123&r2=1853124&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Thu Feb 7 12:36:12 2019
@@ -45,6 +45,16 @@
issues do not "pop up" wrt. others).
-->
<section name="Tomcat 9.0.17 (markt)" rtext="in development">
+ <subsection name="Catalina">
+ <changelog>
+ <fix>
+ Refactor how cookies are transferred from the base request to a
+ <code>PushBuilder</code> so that they are accessible, and may be
edited,
+ via the standard <code>PushBuilder</code> methods for working with HTTP
+ headers. (markt)
+ </fix>
+ </changelog>
+ </subsection>
<subsection name="WebSocket">
<changelog>
<scode>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]