Package org.microproxy.http
Record Class HttpVersion
java.lang.Object
java.lang.Record
org.microproxy.http.HttpVersion
- Record Components:
majorVersion- non-negative major version numberminorVersion- non-negative minor version number
An HTTP protocol version such as
HTTP/1.1.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final HttpVersionstatic final HttpVersionstatic final HttpVersionHTTP/2: the version of requests that arrived on an HTTP/2 stream.static final HttpVersionHTTP/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 -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleanReturns whether connections are persistent by default for this version (HTTP/1.1 and later).intReturns the value of themajorVersionrecord component.intReturns the value of theminorVersionrecord component.text()Returns the protocol version token, such asHTTP/1.1.toString()Returns a string representation of this record class.static HttpVersionParsesHTTP/x.y, with one digit per version number.
-
Field Details
-
HTTP_1_0
-
HTTP_1_1
-
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
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 numberminorVersion- non-negative minor version number- Throws:
IllegalArgumentException- if either version number is negative
-
-
Method Details
-
valueOf
ParsesHTTP/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
Returns the protocol version token, such asHTTP/1.1.- Returns:
- the protocol version token, such as
HTTP/1.1
-
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. -
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. -
equals
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 '=='. -
majorVersion
public int majorVersion()Returns the value of themajorVersionrecord component.- Returns:
- the value of the
majorVersionrecord component
-
minorVersion
public int minorVersion()Returns the value of theminorVersionrecord component.- Returns:
- the value of the
minorVersionrecord component
-