abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r599202 - /incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/AbderaClient.java
Date Wed, 28 Nov 2007 23:38:56 GMT
Author: jmsnell
Date: Wed Nov 28 15:38:53 2007
New Revision: 599202

URL: http://svn.apache.org/viewvc?rev=599202&view=rev
Log:
Utility methods for getting cookies for a specific domain / path

Modified:
    incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/AbderaClient.java

Modified: incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/AbderaClient.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/AbderaClient.java?rev=599202&r1=599201&r2=599202&view=diff
==============================================================================
--- incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/AbderaClient.java
(original)
+++ incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/AbderaClient.java
Wed Nov 28 15:38:53 2007
@@ -20,6 +20,7 @@
 import java.io.InputStream;
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
@@ -700,6 +701,30 @@
    */
   public Cookie[] getCookies() {
     return client.getState().getCookies();
+  }
+  
+  /**
+   * Get the cookies for a specific domain and path
+   */
+  public Cookie[] getCookies(String domain, String path) {
+    Cookie[] cookies = getCookies();
+    List<Cookie> list = new ArrayList<Cookie>();
+    for (Cookie cookie : cookies) {
+      String test = cookie.getDomain();
+      if (test.startsWith(".")) test = test.substring(1);
+      if ((domain.endsWith(test) || test.endsWith(domain)) && 
+          (path == null || cookie.getPath().startsWith(path))) {
+        list.add(cookie);
+      }
+    }
+    return list.toArray(new Cookie[list.size()]);
+  }
+  
+  /**
+   * Get the cookies for a specific domain
+   */
+  public Cookie[] getCookies(String domain) {
+    return getCookies(domain,null);
   }
   
   /**



Mime
View raw message