• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/cookie/CookieSpec.java $
3  * $Revision: 603563 $
4  * $Date: 2007-12-12 03:17:55 -0800 (Wed, 12 Dec 2007) $
5  *
6  * ====================================================================
7  * Licensed to the Apache Software Foundation (ASF) under one
8  * or more contributor license agreements.  See the NOTICE file
9  * distributed with this work for additional information
10  * regarding copyright ownership.  The ASF licenses this file
11  * to you under the Apache License, Version 2.0 (the
12  * "License"); you may not use this file except in compliance
13  * with the License.  You may obtain a copy of the License at
14  *
15  *   http://www.apache.org/licenses/LICENSE-2.0
16  *
17  * Unless required by applicable law or agreed to in writing,
18  * software distributed under the License is distributed on an
19  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
20  * KIND, either express or implied.  See the License for the
21  * specific language governing permissions and limitations
22  * under the License.
23  * ====================================================================
24  *
25  * This software consists of voluntary contributions made by many
26  * individuals on behalf of the Apache Software Foundation.  For more
27  * information on the Apache Software Foundation, please see
28  * <http://www.apache.org/>.
29  *
30  */
31 
32 package org.apache.http.cookie;
33 
34 import java.util.List;
35 
36 import org.apache.http.Header;
37 
38 /**
39  * Defines the cookie management specification.
40  * <p>Cookie management specification must define
41  * <ul>
42  *   <li> rules of parsing "Set-Cookie" header
43  *   <li> rules of validation of parsed cookies
44  *   <li>  formatting of "Cookie" header
45  * </ul>
46  * for a given host, port and path of origin
47  *
48  * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
49  * @author <a href="mailto:jsdever@apache.org">Jeff Dever</a>
50  *
51  * @since 4.0
52  *
53  * @deprecated Please use {@link java.net.URL#openConnection} instead.
54  *     Please visit <a href="http://android-developers.blogspot.com/2011/09/androids-http-clients.html">this webpage</a>
55  *     for further details.
56  */
57 @Deprecated
58 public interface CookieSpec {
59 
60     /**
61      * Returns version of the state management this cookie specification
62      * conforms to.
63      *
64      * @return version of the state management specification
65      */
getVersion()66     int getVersion();
67 
68     /**
69       * Parse the <tt>"Set-Cookie"</tt> Header into an array of Cookies.
70       *
71       * <p>This method will not perform the validation of the resultant
72       * {@link Cookie}s</p>
73       *
74       * @see #validate
75       *
76       * @param header the <tt>Set-Cookie</tt> received from the server
77       * @param origin details of the cookie origin
78       * @return an array of <tt>Cookie</tt>s parsed from the header
79       * @throws MalformedCookieException if an exception occurs during parsing
80       */
parse(Header header, CookieOrigin origin)81     List<Cookie> parse(Header header, CookieOrigin origin) throws MalformedCookieException;
82 
83     /**
84       * Validate the cookie according to validation rules defined by the
85       *  cookie specification.
86       *
87       * @param cookie the Cookie to validate
88       * @param origin details of the cookie origin
89       * @throws MalformedCookieException if the cookie is invalid
90       */
validate(Cookie cookie, CookieOrigin origin)91     void validate(Cookie cookie, CookieOrigin origin) throws MalformedCookieException;
92 
93     /**
94      * Determines if a Cookie matches the target location.
95      *
96      * @param cookie the Cookie to be matched
97      * @param origin the target to test against
98      *
99      * @return <tt>true</tt> if the cookie should be submitted with a request
100      *  with given attributes, <tt>false</tt> otherwise.
101      */
match(Cookie cookie, CookieOrigin origin)102     boolean match(Cookie cookie, CookieOrigin origin);
103 
104     /**
105      * Create <tt>"Cookie"</tt> headers for an array of Cookies.
106      *
107      * @param cookies the Cookies format into a Cookie header
108      * @return a Header for the given Cookies.
109      * @throws IllegalArgumentException if an input parameter is illegal
110      */
formatCookies(List<Cookie> cookies)111     List<Header> formatCookies(List<Cookie> cookies);
112 
113     /**
114      * Returns a request header identifying what version of the state management
115      * specification is understood. May be <code>null</code> if the cookie
116      * specification does not support <tt>Cookie2</tt> header.
117      */
getVersionHeader()118     Header getVersionHeader();
119 
120 }
121