mobile/android/thirdparty/ch/boye/httpclientandroidlib/HttpVersion.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/HttpVersion.java	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,106 @@
     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;
    1.32 +
    1.33 +import java.io.Serializable;
    1.34 +
    1.35 +/**
    1.36 + * Represents an HTTP version. HTTP uses a "major.minor" numbering
    1.37 + * scheme to indicate versions of the protocol.
    1.38 + * <p>
    1.39 + * The version of an HTTP message is indicated by an HTTP-Version field
    1.40 + * in the first line of the message.
    1.41 + * </p>
    1.42 + * <pre>
    1.43 + *     HTTP-Version   = "HTTP" "/" 1*DIGIT "." 1*DIGIT
    1.44 + * </pre>
    1.45 + *
    1.46 + * @since 4.0
    1.47 + */
    1.48 +public final class HttpVersion extends ProtocolVersion
    1.49 +    implements Serializable {
    1.50 +
    1.51 +    private static final long serialVersionUID = -5856653513894415344L;
    1.52 +
    1.53 +    /** The protocol name. */
    1.54 +    public static final String HTTP = "HTTP";
    1.55 +
    1.56 +    /** HTTP protocol version 0.9 */
    1.57 +    public static final HttpVersion HTTP_0_9 = new HttpVersion(0, 9);
    1.58 +
    1.59 +    /** HTTP protocol version 1.0 */
    1.60 +    public static final HttpVersion HTTP_1_0 = new HttpVersion(1, 0);
    1.61 +
    1.62 +    /** HTTP protocol version 1.1 */
    1.63 +    public static final HttpVersion HTTP_1_1 = new HttpVersion(1, 1);
    1.64 +
    1.65 +
    1.66 +    /**
    1.67 +     * Create an HTTP protocol version designator.
    1.68 +     *
    1.69 +     * @param major   the major version number of the HTTP protocol
    1.70 +     * @param minor   the minor version number of the HTTP protocol
    1.71 +     *
    1.72 +     * @throws IllegalArgumentException if either major or minor version number is negative
    1.73 +     */
    1.74 +    public HttpVersion(int major, int minor) {
    1.75 +        super(HTTP, major, minor);
    1.76 +    }
    1.77 +
    1.78 +
    1.79 +    /**
    1.80 +     * Obtains a specific HTTP version.
    1.81 +     *
    1.82 +     * @param major     the major version
    1.83 +     * @param minor     the minor version
    1.84 +     *
    1.85 +     * @return  an instance of {@link HttpVersion} with the argument version
    1.86 +     */
    1.87 +    public ProtocolVersion forVersion(int major, int minor) {
    1.88 +
    1.89 +        if ((major == this.major) && (minor == this.minor)) {
    1.90 +            return this;
    1.91 +        }
    1.92 +
    1.93 +        if (major == 1) {
    1.94 +            if (minor == 0) {
    1.95 +                return HTTP_1_0;
    1.96 +            }
    1.97 +            if (minor == 1) {
    1.98 +                return HTTP_1_1;
    1.99 +            }
   1.100 +        }
   1.101 +        if ((major == 0) && (minor == 9)) {
   1.102 +            return HTTP_0_9;
   1.103 +        }
   1.104 +
   1.105 +        // argument checking is done in the constructor
   1.106 +        return new HttpVersion(major, minor);
   1.107 +    }
   1.108 +
   1.109 +}

mercurial