org.apache.hc.core5.http

## Class HttpVersion

- java.lang.Object
- - org.apache.hc.core5.http.ProtocolVersion
  - - org.apache.hc.core5.http.HttpVersion

- All Implemented Interfaces:
    Serializable

      @Contract(threading=IMMUTABLE)
      public final class HttpVersion
      extends ProtocolVersion

  Represents an HTTP version. HTTP uses a "major.minor" numbering scheme to indicate versions of the protocol.

  The version of an HTTP message is indicated by an HTTP-Version field in the first line of the message.

  Since:
    4.0
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static HttpVersion[]` | `ALL` All HTTP versions known to HttpCore.
    `static HttpVersion` | `DEFAULT` HTTP/1.1 is default
    `static String` | `HTTP` The protocol name.
    `static HttpVersion` | `HTTP_0_9` HTTP protocol version 0.9
    `static HttpVersion` | `HTTP_1_0` HTTP protocol version 1.0
    `static HttpVersion` | `HTTP_1_1` HTTP protocol version 1.1
    `static HttpVersion` | `HTTP_2`
    `static HttpVersion` | `HTTP_2_0` HTTP protocol version 2.0

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `HttpVersion(int major, int minor)` Creates an HTTP protocol version designator.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static HttpVersion` | `get(int major, int minor)` Gets a specific instance or creates a new one.

    - ### Methods inherited from class org.apache.hc.core5.http.ProtocolVersion

      `compareToVersion, equals, equals, format, getMajor, getMinor, getProtocol, greaterEquals, hashCode, isComparable, lessEquals, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### HTTP

          public static final String HTTP

      The protocol name.
      See Also:
        Constant Field Values

    - #### HTTP_0_9

          public static final HttpVersion HTTP_0_9

      HTTP protocol version 0.9

    - #### HTTP_1_0

          public static final HttpVersion HTTP_1_0

      HTTP protocol version 1.0

    - #### HTTP_1_1

          public static final HttpVersion HTTP_1_1

      HTTP protocol version 1.1

    - #### HTTP_2_0

          public static final HttpVersion HTTP_2_0

      HTTP protocol version 2.0

    - #### HTTP_2

          public static final HttpVersion HTTP_2

    - #### DEFAULT

          public static final HttpVersion DEFAULT

      HTTP/1.1 is default

    - #### ALL

          public static final HttpVersion[] ALL

      All HTTP versions known to HttpCore.

  - ### Constructor Detail

    - #### HttpVersion

          public HttpVersion(int major,
                     int minor)

      Creates an HTTP protocol version designator.
      Parameters:
        `major` - the major version number of the HTTP protocol
        `minor` - the minor version number of the HTTP protocol
      Throws:
        `IllegalArgumentException` - if either major or minor version number is negative

  - ### Method Detail

    - #### get

          public static HttpVersion get(int major,
                        int minor)

      Gets a specific instance or creates a new one.
      Parameters:
        `major` - the major version
        `minor` - the minor version
      Returns:
        an instance of `HttpVersion` with the argument version, never null.
      Throws:
        `IllegalArgumentException` - if either major or minor version number is negative
      Since:
        5.0

Copyright © 2005–2020 The Apache Software Foundation. All rights reserved.