chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1664382 - in /chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src: main/java/org/apache/chemistry/opencmis/client/bindings/spi/cookies/ test/java/org/apache/chemistry/opencmis/client/bindings/misc/
Date Thu, 05 Mar 2015 16:00:42 GMT
Author: fmui
Date: Thu Mar  5 16:00:42 2015
New Revision: 1664382

URL: http://svn.apache.org/r1664382
Log:
client: send all cookies in RFC 6265 style, which seems to be the de-facto standard nowadays


Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/cookies/CmisCookieManager.java
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/misc/CookiesTest.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/cookies/CmisCookieManager.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/cookies/CmisCookieManager.java?rev=1664382&r1=1664381&r2=1664382&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/cookies/CmisCookieManager.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/cookies/CmisCookieManager.java
Thu Mar  5 16:00:42 2015
@@ -123,30 +123,22 @@ public class CmisCookieManager implement
 
     private static Map<String, List<String>> getCookieMap(List<CmisHttpCookie>
cookies,
             Map<String, List<String>> requestHeaders) {
-        HashMap<String, List<String>> map = new HashMap<String, List<String>>();
-        ArrayList<String> cookieStr = new ArrayList<String>();
-        // If all cookies are version 1, add a "$Version="1"" header
-        boolean versionOne = true;
-        for (CmisHttpCookie cookie : cookies) {
-            if (cookie.getVersion() == 0) {
-                versionOne = false;
-                break;
-            }
-        }
-        if (versionOne && !cookies.isEmpty()) {
-            cookieStr.add("$Version=\"1\"");
-        }
-        // add every cookie's string representation into map
-        for (CmisHttpCookie cookie : cookies) {
-            cookieStr.add(cookie.toString());
+        if (cookies.isEmpty()) {
+            return Collections.emptyMap();
         }
 
-        if (cookieStr.isEmpty()) {
-            return Collections.emptyMap();
+        StringBuilder cookieHeaderStr = new StringBuilder();
+
+        for (CmisHttpCookie cookie : cookies) {
+            if (cookieHeaderStr.length() > 0) {
+                cookieHeaderStr.append("; ");
+            }
+            cookieHeaderStr.append(cookie.getName());
+            cookieHeaderStr.append('=');
+            cookieHeaderStr.append(cookie.getValue());
         }
 
-        map.put("Cookie", cookieStr);
-        return map;
+        return Collections.singletonMap("Cookie", Collections.singletonList(cookieHeaderStr.toString()));
     }
 
     /**

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/misc/CookiesTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/misc/CookiesTest.java?rev=1664382&r1=1664381&r2=1664382&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/misc/CookiesTest.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/misc/CookiesTest.java
Thu Mar  5 16:00:42 2015
@@ -52,9 +52,9 @@ public class CookiesTest extends TestCas
         List<String> cookies = manager.get("https://www.example.com/s/test/abc/s",
new HashMap<String, List<String>>())
                 .get("Cookie");
 
-        assertEquals(2, cookies.size());
-        assertEquals(cookies.get(0), "cookie1=c1-3333");
-        assertEquals(cookies.get(1), "cookie1=c1-2222");
+        assertEquals(1, cookies.size());
+        assertEquals(cookies.get(0), "cookie1=c1-3333; cookie1=c1-2222");
+        //assertEquals(cookies.get(1), "cookie1=c1-2222");
     }
 
     private void addCookie(CmisCookieManager manager, String url, String name, String value,
String path) {



Mime
View raw message