mobile/android/thirdparty/ch/boye/httpclientandroidlib/cookie/CookieSpec.java

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

     1 /*
     2  * ====================================================================
     3  * Licensed to the Apache Software Foundation (ASF) under one
     4  * or more contributor license agreements.  See the NOTICE file
     5  * distributed with this work for additional information
     6  * regarding copyright ownership.  The ASF licenses this file
     7  * to you under the Apache License, Version 2.0 (the
     8  * "License"); you may not use this file except in compliance
     9  * with the License.  You may obtain a copy of the License at
    10  *
    11  *   http://www.apache.org/licenses/LICENSE-2.0
    12  *
    13  * Unless required by applicable law or agreed to in writing,
    14  * software distributed under the License is distributed on an
    15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    16  * KIND, either express or implied.  See the License for the
    17  * specific language governing permissions and limitations
    18  * under the License.
    19  * ====================================================================
    20  *
    21  * This software consists of voluntary contributions made by many
    22  * individuals on behalf of the Apache Software Foundation.  For more
    23  * information on the Apache Software Foundation, please see
    24  * <http://www.apache.org/>.
    25  *
    26  */
    28 package ch.boye.httpclientandroidlib.cookie;
    30 import java.util.List;
    32 import ch.boye.httpclientandroidlib.Header;
    34 /**
    35  * Defines the cookie management specification.
    36  * <p>Cookie management specification must define
    37  * <ul>
    38  *   <li> rules of parsing "Set-Cookie" header
    39  *   <li> rules of validation of parsed cookies
    40  *   <li>  formatting of "Cookie" header
    41  * </ul>
    42  * for a given host, port and path of origin
    43  *
    44  *
    45  * @since 4.0
    46  */
    47 public interface CookieSpec {
    49     /**
    50      * Returns version of the state management this cookie specification
    51      * conforms to.
    52      *
    53      * @return version of the state management specification
    54      */
    55     int getVersion();
    57     /**
    58       * Parse the <tt>"Set-Cookie"</tt> Header into an array of Cookies.
    59       *
    60       * <p>This method will not perform the validation of the resultant
    61       * {@link Cookie}s</p>
    62       *
    63       * @see #validate
    64       *
    65       * @param header the <tt>Set-Cookie</tt> received from the server
    66       * @param origin details of the cookie origin
    67       * @return an array of <tt>Cookie</tt>s parsed from the header
    68       * @throws MalformedCookieException if an exception occurs during parsing
    69       */
    70     List<Cookie> parse(Header header, CookieOrigin origin) throws MalformedCookieException;
    72     /**
    73       * Validate the cookie according to validation rules defined by the
    74       *  cookie specification.
    75       *
    76       * @param cookie the Cookie to validate
    77       * @param origin details of the cookie origin
    78       * @throws MalformedCookieException if the cookie is invalid
    79       */
    80     void validate(Cookie cookie, CookieOrigin origin) throws MalformedCookieException;
    82     /**
    83      * Determines if a Cookie matches the target location.
    84      *
    85      * @param cookie the Cookie to be matched
    86      * @param origin the target to test against
    87      *
    88      * @return <tt>true</tt> if the cookie should be submitted with a request
    89      *  with given attributes, <tt>false</tt> otherwise.
    90      */
    91     boolean match(Cookie cookie, CookieOrigin origin);
    93     /**
    94      * Create <tt>"Cookie"</tt> headers for an array of Cookies.
    95      *
    96      * @param cookies the Cookies format into a Cookie header
    97      * @return a Header for the given Cookies.
    98      * @throws IllegalArgumentException if an input parameter is illegal
    99      */
   100     List<Header> formatCookies(List<Cookie> cookies);
   102     /**
   103      * Returns a request header identifying what version of the state management
   104      * specification is understood. May be <code>null</code> if the cookie
   105      * specification does not support <tt>Cookie2</tt> header.
   106      */
   107     Header getVersionHeader();
   109 }

mercurial