public class HTTPStatus extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
BAD_REQUEST |
static int |
CONTINUE |
static int |
INTERNAL_SERVER_ERROR |
static int |
INVALID_RANGE |
static int |
NOT_FOUND |
static int |
OK |
static int |
PARTIAL_CONTENT |
static int |
PRECONDITION_FAILED |
| Constructor and Description |
|---|
HTTPStatus()
Creates a new empty HTTPStatus with default values.
|
HTTPStatus(String lineStr)
Creates a new HTTPStatus by parsing a status line string.
|
HTTPStatus(String ver,
int code,
String reason)
Creates a new HTTPStatus with the specified version, code, and reason.
|
| Modifier and Type | Method and Description |
|---|---|
static String |
code2String(int code)
Converts an HTTP status code to its corresponding reason phrase string.
|
String |
getReasonPhrase()
Gets the reason phrase.
|
int |
getStatusCode()
Gets the status code.
|
String |
getVersion()
Gets the HTTP version.
|
boolean |
isSuccessful()
Checks if this status represents a successful response (2xx range).
|
static boolean |
isSuccessful(int statCode)
Checks if the given status code represents a successful response (2xx range).
|
void |
set(String lineStr)
Parses a status line string and sets the version, code, and reason phrase.
|
void |
setReasonPhrase(String value)
Sets the reason phrase.
|
void |
setStatusCode(int value)
Sets the status code.
|
void |
setVersion(String value)
Sets the HTTP version.
|
public static final int BAD_REQUEST
public static final int CONTINUE
public static final int INTERNAL_SERVER_ERROR
public static final int INVALID_RANGE
public static final int NOT_FOUND
public static final int OK
public static final int PARTIAL_CONTENT
public static final int PRECONDITION_FAILED
public HTTPStatus()
public HTTPStatus(String lineStr)
lineStr - the status line to parsepublic static final String code2String(int code)
This method provides the standard HTTP reason phrases for common status codes. If the status code is not recognized, an empty string is returned.
code - the HTTP status code to convertpublic String getReasonPhrase()
public int getStatusCode()
public String getVersion()
public boolean isSuccessful()
public static final boolean isSuccessful(int statCode)
statCode - the status code to checkpublic void set(String lineStr)
lineStr - the status line to parsepublic void setReasonPhrase(String value)
value - the reason phrasepublic void setStatusCode(int value)
value - the status codepublic void setVersion(String value)
value - the HTTP version (e.g., "HTTP/1.1")