Record Class HttpVersion

java.lang.Object
java.lang.Record
org.microproxy.http.HttpVersion
Record Components:
majorVersion - non-negative major version number
minorVersion - non-negative minor version number

public record HttpVersion(int majorVersion, int minorVersion) extends Record
An HTTP protocol version such as HTTP/1.1.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final HttpVersion
     
    static final HttpVersion
     
    static final HttpVersion
    HTTP/2: the version of requests that arrived on an HTTP/2 stream.
    static final HttpVersion
    HTTP/3: the version of requests that arrived on an HTTP/3 (QUIC) stream, and of responses from servers reached over HTTP/3.
  • Constructor Summary

    Constructors
    Constructor
    Description
    HttpVersion(int majorVersion, int minorVersion)
    Creates a protocol version.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    boolean
    Returns whether connections are persistent by default for this version (HTTP/1.1 and later).
    int
    Returns the value of the majorVersion record component.
    int
    Returns the value of the minorVersion record component.
    Returns the protocol version token, such as HTTP/1.1.
    Returns a string representation of this record class.
    Parses HTTP/x.y, with one digit per version number.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • HTTP_1_0

      public static final HttpVersion HTTP_1_0
    • HTTP_1_1

      public static final HttpVersion HTTP_1_1
    • HTTP_2_0

      public static final HttpVersion HTTP_2_0
      HTTP/2: the version of requests that arrived on an HTTP/2 stream. HTTP/2 has no request line; the proxy forwards such requests to servers as HTTP/1.1.
    • HTTP_3_0

      public static final HttpVersion HTTP_3_0
      HTTP/3: the version of requests that arrived on an HTTP/3 (QUIC) stream, and of responses from servers reached over HTTP/3. Like HTTP/2 it has no request line; the proxy forwards such requests to HTTP/1.1 servers as HTTP/1.1.
  • Constructor Details

    • HttpVersion

      public HttpVersion(int majorVersion, int minorVersion)
      Creates a protocol version.
      Parameters:
      majorVersion - non-negative major version number
      minorVersion - non-negative minor version number
      Throws:
      IllegalArgumentException - if either version number is negative
  • Method Details

    • valueOf

      public static HttpVersion valueOf(String text)
      Parses HTTP/x.y, with one digit per version number.
      Parameters:
      text - protocol version token
      Returns:
      the parsed version, reusing well-known constants when possible
      Throws:
      IllegalArgumentException - if the token does not have the required format
    • isKeepAliveDefault

      public boolean isKeepAliveDefault()
      Returns whether connections are persistent by default for this version (HTTP/1.1 and later).
      Returns:
      whether connections are persistent by default for this version (HTTP/1.1 and later)
    • text

      public String text()
      Returns the protocol version token, such as HTTP/1.1.
      Returns:
      the protocol version token, such as HTTP/1.1
    • toString

      public String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • majorVersion

      public int majorVersion()
      Returns the value of the majorVersion record component.
      Returns:
      the value of the majorVersion record component
    • minorVersion

      public int minorVersion()
      Returns the value of the minorVersion record component.
      Returns:
      the value of the minorVersion record component