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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/mobile/android/thirdparty/ch/boye/httpclientandroidlib/cookie/CookieSpec.java	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,109 @@
     1.4 +/*
     1.5 + * ====================================================================
     1.6 + * Licensed to the Apache Software Foundation (ASF) under one
     1.7 + * or more contributor license agreements.  See the NOTICE file
     1.8 + * distributed with this work for additional information
     1.9 + * regarding copyright ownership.  The ASF licenses this file
    1.10 + * to you under the Apache License, Version 2.0 (the
    1.11 + * "License"); you may not use this file except in compliance
    1.12 + * with the License.  You may obtain a copy of the License at
    1.13 + *
    1.14 + *   http://www.apache.org/licenses/LICENSE-2.0
    1.15 + *
    1.16 + * Unless required by applicable law or agreed to in writing,
    1.17 + * software distributed under the License is distributed on an
    1.18 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    1.19 + * KIND, either express or implied.  See the License for the
    1.20 + * specific language governing permissions and limitations
    1.21 + * under the License.
    1.22 + * ====================================================================
    1.23 + *
    1.24 + * This software consists of voluntary contributions made by many
    1.25 + * individuals on behalf of the Apache Software Foundation.  For more
    1.26 + * information on the Apache Software Foundation, please see
    1.27 + * <http://www.apache.org/>.
    1.28 + *
    1.29 + */
    1.30 +
    1.31 +package ch.boye.httpclientandroidlib.cookie;
    1.32 +
    1.33 +import java.util.List;
    1.34 +
    1.35 +import ch.boye.httpclientandroidlib.Header;
    1.36 +
    1.37 +/**
    1.38 + * Defines the cookie management specification.
    1.39 + * <p>Cookie management specification must define
    1.40 + * <ul>
    1.41 + *   <li> rules of parsing "Set-Cookie" header
    1.42 + *   <li> rules of validation of parsed cookies
    1.43 + *   <li>  formatting of "Cookie" header
    1.44 + * </ul>
    1.45 + * for a given host, port and path of origin
    1.46 + *
    1.47 + *
    1.48 + * @since 4.0
    1.49 + */
    1.50 +public interface CookieSpec {
    1.51 +
    1.52 +    /**
    1.53 +     * Returns version of the state management this cookie specification
    1.54 +     * conforms to.
    1.55 +     *
    1.56 +     * @return version of the state management specification
    1.57 +     */
    1.58 +    int getVersion();
    1.59 +
    1.60 +    /**
    1.61 +      * Parse the <tt>"Set-Cookie"</tt> Header into an array of Cookies.
    1.62 +      *
    1.63 +      * <p>This method will not perform the validation of the resultant
    1.64 +      * {@link Cookie}s</p>
    1.65 +      *
    1.66 +      * @see #validate
    1.67 +      *
    1.68 +      * @param header the <tt>Set-Cookie</tt> received from the server
    1.69 +      * @param origin details of the cookie origin
    1.70 +      * @return an array of <tt>Cookie</tt>s parsed from the header
    1.71 +      * @throws MalformedCookieException if an exception occurs during parsing
    1.72 +      */
    1.73 +    List<Cookie> parse(Header header, CookieOrigin origin) throws MalformedCookieException;
    1.74 +
    1.75 +    /**
    1.76 +      * Validate the cookie according to validation rules defined by the
    1.77 +      *  cookie specification.
    1.78 +      *
    1.79 +      * @param cookie the Cookie to validate
    1.80 +      * @param origin details of the cookie origin
    1.81 +      * @throws MalformedCookieException if the cookie is invalid
    1.82 +      */
    1.83 +    void validate(Cookie cookie, CookieOrigin origin) throws MalformedCookieException;
    1.84 +
    1.85 +    /**
    1.86 +     * Determines if a Cookie matches the target location.
    1.87 +     *
    1.88 +     * @param cookie the Cookie to be matched
    1.89 +     * @param origin the target to test against
    1.90 +     *
    1.91 +     * @return <tt>true</tt> if the cookie should be submitted with a request
    1.92 +     *  with given attributes, <tt>false</tt> otherwise.
    1.93 +     */
    1.94 +    boolean match(Cookie cookie, CookieOrigin origin);
    1.95 +
    1.96 +    /**
    1.97 +     * Create <tt>"Cookie"</tt> headers for an array of Cookies.
    1.98 +     *
    1.99 +     * @param cookies the Cookies format into a Cookie header
   1.100 +     * @return a Header for the given Cookies.
   1.101 +     * @throws IllegalArgumentException if an input parameter is illegal
   1.102 +     */
   1.103 +    List<Header> formatCookies(List<Cookie> cookies);
   1.104 +
   1.105 +    /**
   1.106 +     * Returns a request header identifying what version of the state management
   1.107 +     * specification is understood. May be <code>null</code> if the cookie
   1.108 +     * specification does not support <tt>Cookie2</tt> header.
   1.109 +     */
   1.110 +    Header getVersionHeader();
   1.111 +
   1.112 +}

mercurial