public class HttpStatus extends Object
An HttpStatus contains a Status-Code (e.g. 200) and a Reason-Phrase (e.g. "OK"). See RFC2616 §6.1.1 Status Code and Reason Phrase.
Well-known status are available as constants like HttpStatus.c200_OK
,
or can be retrieved by Status-Code like HttpStatus.of(200)
.
This class is immutable.
Constructor and Description |
---|
HttpStatus(int code,
String phrase)
Create an HttpStatus instance.
|
Instance Methods | |
---|---|
int |
code()
The Status-Code, for example, 200.
|
String |
phrase()
The Reason-Phrase, for example, "OK".
|
int |
hashCode()
Return the
Status-Code as the hash-code. |
boolean |
equals(Object that)
Return true iff `that` object is an HttpStatus with the same Status-Code.
|
String |
toString()
Return a string of
"Status-Code SP Reason-Phrase" , for example, "200 OK". |
Static Method | |
HttpStatus |
of(int code)
Get an HttpStatus instance with the Status-Code.
|
public static final HttpStatus c100_Continue
public static final HttpStatus c101_Switching_Protocols
public static final HttpStatus c200_OK
public static final HttpStatus c201_Created
public static final HttpStatus c202_Accepted
public static final HttpStatus c203_Non_Authoritative_Information
public static final HttpStatus c204_No_Content
public static final HttpStatus c205_Reset_Content
public static final HttpStatus c206_Partial_Content
public static final HttpStatus c300_Multiple_Choices
public static final HttpStatus c301_Moved_Permanently
public static final HttpStatus c302_Found
public static final HttpStatus c303_See_Other
public static final HttpStatus c304_Not_Modified
public static final HttpStatus c305_Use_Proxy
public static final HttpStatus c307_Temporary_Redirect
public static final HttpStatus c308_Permanent_Redirect
public static final HttpStatus c400_Bad_Request
public static final HttpStatus c401_Unauthorized
public static final HttpStatus c402_Payment_Required
public static final HttpStatus c403_Forbidden
public static final HttpStatus c404_Not_Found
public static final HttpStatus c405_Method_Not_Allowed
public static final HttpStatus c406_Not_Acceptable
public static final HttpStatus c407_Proxy_Authentication_Required
public static final HttpStatus c408_Request_Timeout
public static final HttpStatus c409_Conflict
public static final HttpStatus c410_Gone
public static final HttpStatus c411_Length_Required
public static final HttpStatus c412_Precondition_Failed
public static final HttpStatus c413_Request_Entity_Too_Large
public static final HttpStatus c414_URI_Too_Long
public static final HttpStatus c415_Unsupported_Media_Type
public static final HttpStatus c416_Requested_Range_Not_Satisfiable
public static final HttpStatus c417_Expectation_Failed
public static final HttpStatus c500_Internal_Server_Error
public static final HttpStatus c501_Not_Implemented
public static final HttpStatus c502_Bad_Gateway
public static final HttpStatus c503_Service_Unavailable
public static final HttpStatus c504_Gateway_Timeout
public static final HttpStatus c505_HTTP_Version_Not_Supported
public HttpStatus(int code, String phrase)
code
- the Status-Code. required: 100<=code<=599
phrase
- the Reason-Phrasepublic int code()
public String phrase()
public int hashCode()
Status-Code
as the hash-code.public boolean equals(Object that)
public String toString()
"Status-Code SP Reason-Phrase"
, for example, "200 OK".public static HttpStatus of(int code)
If the Status-Code is well-known, a cached instance is returned; otherwise a new HttpStatus instance is returned.
code
- the Status-Code. required: 100<=code<=999