1 /* 2 * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/HttpVersion.java $ 3 * $Revision: 609106 $ 4 * $Date: 2008-01-05 01:15:42 -0800 (Sat, 05 Jan 2008) $ 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; 33 34 import java.io.Serializable; 35 36 /** 37 * Represents an HTTP version, as specified in RFC 2616. 38 * 39 * @author <a href="mailto:oleg@ural.ru">Oleg Kalnichevski</a> 40 * 41 * @version $Revision: 609106 $ $Date: 2008-01-05 01:15:42 -0800 (Sat, 05 Jan 2008) $ 42 * 43 * @deprecated Please use {@link java.net.URL#openConnection} instead. 44 * Please visit <a href="http://android-developers.blogspot.com/2011/09/androids-http-clients.html">this webpage</a> 45 * for further details. 46 */ 47 @Deprecated 48 public final class HttpVersion extends ProtocolVersion 49 implements Serializable { 50 51 private static final long serialVersionUID = -5856653513894415344L; 52 53 /** The protocol name. */ 54 public static final String HTTP = "HTTP"; 55 56 /** HTTP protocol version 0.9 */ 57 public static final HttpVersion HTTP_0_9 = new HttpVersion(0, 9); 58 59 /** HTTP protocol version 1.0 */ 60 public static final HttpVersion HTTP_1_0 = new HttpVersion(1, 0); 61 62 /** HTTP protocol version 1.1 */ 63 public static final HttpVersion HTTP_1_1 = new HttpVersion(1, 1); 64 65 66 /** 67 * Create an HTTP protocol version designator. 68 * 69 * @param major the major version number of the HTTP protocol 70 * @param minor the minor version number of the HTTP protocol 71 * 72 * @throws IllegalArgumentException if either major or minor version number is negative 73 */ 74 public HttpVersion(int major, int minor) { 75 super(HTTP, major, minor); 76 } 77 78 79 /** 80 * Obtains a specific HTTP version. 81 * 82 * @param major the major version 83 * @param minor the minor version 84 * 85 * @return an instance of {@link HttpVersion} with the argument version 86 */ 87 public ProtocolVersion forVersion(int major, int minor) { 88 89 if ((major == this.major) && (minor == this.minor)) { 90 return this; 91 } 92 93 if (major == 1) { 94 if (minor == 0) { 95 return HTTP_1_0; 96 } 97 if (minor == 1) { 98 return HTTP_1_1; 99 } 100 } 101 if ((major == 0) && (minor == 9)) { 102 return HTTP_0_9; 103 } 104 105 // argument checking is done in the constructor 106 return new HttpVersion(major, minor); 107 } 108 109 } 110