1 //
2 // ========================================================================
3 // Copyright (c) 1995-2012 Mort Bay Consulting Pty. Ltd.
4 // ------------------------------------------------------------------------
5 // All rights reserved. This program and the accompanying materials
6 // are made available under the terms of the Eclipse Public License v1.0
7 // and Apache License v2.0 which accompanies this distribution.
8 //
9 // The Eclipse Public License is available at
10 // http://www.eclipse.org/legal/epl-v10.html
11 //
12 // The Apache License v2.0 is available at
13 // http://www.opensource.org/licenses/apache2.0.php
14 //
15 // You may elect to redistribute this code under either of these licenses.
16 // ========================================================================
17 //
18
19 package org.eclipse.jetty.client.api;
20
21 import java.util.List;
22
23 import org.eclipse.jetty.client.HttpClient;
24 import org.eclipse.jetty.http.HttpCookie;
25
26 /**
27 * A store for HTTP cookies that offers methods to match cookies for a given destination and path.
28 *
29 * @see HttpClient#getCookieStore()
30 */
31 public interface CookieStore
32 {
33 /**
34 * Returns the non-expired cookies that match the given destination and path,
35 * recursively matching parent paths (for the same domain) and parent domains
36 * (for the root path).
37 *
38 * @param destination the destination representing the domain
39 * @param path the request path
40 * @return the list of matching cookies
41 */
42 List<HttpCookie> findCookies(Destination destination, String path);
43
44 /**
45 * Adds the given cookie to this store for the given destination.
46 * If the cookie's domain and the destination host do not match, the cookie is not added.
47 *
48 * @param destination the destination the cookie should belong to
49 * @param cookie the cookie to add
50 * @return whether the cookie has been added or not
51 */
52 boolean addCookie(Destination destination, HttpCookie cookie);
53
54 /**
55 * Removes all the cookies from this store.
56 */
57 void clear();
58 }