Repository: cxf Updated Branches: refs/heads/2.7.x-fixes 28365ff96 -> b79e79332
[CXF-6204] Ending up doing the right code Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/b79e7933 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/b79e7933 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/b79e7933 Branch: refs/heads/2.7.x-fixes Commit: b79e793326ce247465847e23757c53b1ecf09596 Parents: 28365ff Author: Sergey Beryozkin <[email protected]> Authored: Mon Jan 19 17:12:23 2015 +0000 Committer: Sergey Beryozkin <[email protected]> Committed: Mon Jan 19 17:14:46 2015 +0000 ---------------------------------------------------------------------- .../cxf/jaxrs/impl/NewCookieHeaderProvider.java | 40 +++++++++----------- .../jaxrs/impl/NewCookieHeaderProviderTest.java | 2 +- 2 files changed, 19 insertions(+), 23 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/b79e7933/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/NewCookieHeaderProvider.java ---------------------------------------------------------------------- diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/NewCookieHeaderProvider.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/NewCookieHeaderProvider.java index 63b8819..a050b86 100644 --- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/NewCookieHeaderProvider.java +++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/NewCookieHeaderProvider.java @@ -33,7 +33,7 @@ public class NewCookieHeaderProvider implements HeaderDelegate<NewCookie> { private static final String COMMENT = "Comment"; private static final String SECURE = "Secure"; private static final String EXPIRES = "Expires"; - + public NewCookie fromString(String c) { if (c == null) { @@ -51,31 +51,27 @@ public class NewCookieHeaderProvider implements HeaderDelegate<NewCookie> { String[] tokens = StringUtils.split(c, ";"); for (String token : tokens) { String theToken = token.trim(); - String theTokenUC = theToken; - if (!StringUtils.isEmpty(theTokenUC) && Character.isLowerCase(theTokenUC.charAt(0))) { - theTokenUC = StringUtils.capitalize(theToken); - } - if (theTokenUC.startsWith(VERSION)) { - // should we throw an exception if it's not == 1 ? - } else if (theTokenUC.startsWith(MAX_AGE)) { - maxAge = Integer.parseInt(theTokenUC.substring(MAX_AGE.length() + 1)); - } else if (theTokenUC.startsWith(PATH)) { - path = theTokenUC.substring(PATH.length() + 1); - } else if (theTokenUC.startsWith(DOMAIN)) { - domain = theTokenUC.substring(DOMAIN.length() + 1); - } else if (theTokenUC.startsWith(COMMENT)) { - comment = theTokenUC.substring(COMMENT.length() + 1); - } else if (theTokenUC.startsWith(SECURE)) { + + int sepIndex = theToken.indexOf('='); + String paramName = sepIndex != -1 ? theToken.substring(0, sepIndex) : theToken; + String paramValue = sepIndex == theToken.length() + 1 ? null : theToken.substring(sepIndex + 1); + + if (paramName.equalsIgnoreCase(MAX_AGE)) { + maxAge = Integer.parseInt(paramValue); + } else if (paramName.equalsIgnoreCase(PATH)) { + path = paramValue; + } else if (paramName.equalsIgnoreCase(DOMAIN)) { + domain = paramValue; + } else if (paramName.equalsIgnoreCase(COMMENT)) { + comment = paramValue; + } else if (paramName.equalsIgnoreCase(SECURE)) { isSecure = true; - } else if (theTokenUC.startsWith(EXPIRES)) { + } else if (paramName.equalsIgnoreCase(EXPIRES) || paramName.equalsIgnoreCase(VERSION)) { // ignore continue; } else { - int i = theToken.indexOf('='); - if (i != -1) { - name = theToken.substring(0, i); - value = i == theToken.length() + 1 ? "" : theToken.substring(i + 1); - } + name = paramName; + value = paramValue; } } http://git-wip-us.apache.org/repos/asf/cxf/blob/b79e7933/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/NewCookieHeaderProviderTest.java ---------------------------------------------------------------------- diff --git a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/NewCookieHeaderProviderTest.java b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/NewCookieHeaderProviderTest.java index 9b2b51e..6e62952 100644 --- a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/NewCookieHeaderProviderTest.java +++ b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/NewCookieHeaderProviderTest.java @@ -62,7 +62,7 @@ public class NewCookieHeaderProviderTest extends Assert { @Test public void testFromComplexStringLowerCase() { NewCookie c = NewCookie.valueOf( - "foo=bar;comment=comment;path=path;max-Age=10;domain=domain;secure;version=1"); + "foo=bar;comment=comment;path=path;max-age=10;domain=domain;secure;version=1"); assertTrue("bar".equals(c.getValue()) && "foo".equals(c.getName()) && 1 == c.getVersion()
