public class HttpVersion extends Object
Instances of this class reflect a particular HTTP version. There are well known instances for HTTP/1.0 and HTTP/1.1; these instances can be compared by identity. Other instances are constructed on demand.
Modifier and Type | Field and Description |
---|---|
static HttpVersion |
Unknown
Instance representing an unknown HTTP version
|
static HttpVersion |
Version_1_0
Well-known instance for HTTP/1.0
|
static HttpVersion |
Version_1_1
Well-known instance for HTTP/1.1
|
Modifier and Type | Method and Description |
---|---|
int |
getMajor() |
int |
getMinor() |
boolean |
isUnknown() |
static HttpVersion |
newInstance(int major,
int minor)
Get an instance for a particular version.
|
static HttpVersion |
parse(String toParse)
Get an instance for a particular version by parsing a HTTP version
string.
|
String |
toString()
Formats this version as a HTTP version string; see
parse()
for details. |
public static final HttpVersion Unknown
public static final HttpVersion Version_1_0
public static final HttpVersion Version_1_1
public static HttpVersion newInstance(int major, int minor)
major
- the major part of the version (e.g. 1 in HTTP/1.0)minor
- the major part of the version (e.g. 0 in HTTP/1.0)IllegalArgumentException
- if major or minor are negativepublic static HttpVersion parse(String toParse) throws ParseException
toParse
- the version string to parseParseException
- if the version string is badly formedpublic boolean isUnknown()
public int getMajor()
public int getMinor()