-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathStatus.java
More file actions
120 lines (104 loc) 路 3.17 KB
/
Copy pathStatus.java
File metadata and controls
120 lines (104 loc) 路 3.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
package express.utils;
/**
* @author Simon Reinisch
* Enum with all status codes.
*/
public enum Status {
// Informational
_100(100, "Continue"),
_101(101, "Switching Protocols"),
_102(102, "Processing"),
// Success
_200(200, "OK"),
_201(201, "Created"),
_202(202, "Accepted"),
_203(203, "Non-authoritative Information"),
_204(204, "No Content"),
_205(205, "Reset Content"),
_206(206, "Partial Content"),
_207(207, "Multi-Status"),
_208(208, "Already Reported"),
_226(226, "IM Used"),
// Redirection
_300(300, "Multiple Choices"),
_301(301, "Moved Permanently"),
_302(302, "Found"),
_303(303, "See Other"),
_304(304, "Not Modified"),
_305(305, "Use Proxy"),
_307(307, "Temporary Redirect"),
_308(308, "Permanent Redirect"),
// Client Error
_400(400, "Bad Request"),
_401(401, "Unauthorized"),
_402(402, "Payment Required"),
_403(403, "Forbidden"),
_404(404, "Not Found"),
_405(405, "Method Not Allowed"),
_406(406, "Not Acceptable"),
_407(407, "Proxy Authentication Required"),
_408(408, "Request Timeout"),
_409(409, "Conflict"),
_410(410, "Gone"),
_411(411, "Length Required"),
_412(412, "Precondition Failed"),
_413(413, "Payload Too Large"),
_414(414, "Request-URI Too Long"),
_415(415, "Unsupported Media Type"),
_416(416, "Requested Range Not Satisfiable"),
_417(417, "Expectation Failed"),
_418(418, "I'm a teapot"),
_421(421, "Misdirected Request"),
_422(422, "Unprocessable Entity"),
_423(423, "Locked"),
_424(424, "Failed Dependency"),
_426(426, "Upgrade Required"),
_428(428, "Precondition Required"),
_429(429, "Too Many Requests"),
_431(431, "Request Header Fields Too Large"),
_444(444, "Connection Closed Without Response"),
_451(451, "Unavailable For Legal Reasons"),
_499(499, "Client Closed Request"),
// Server Error
_500(500, "Internal Server Error"),
_501(501, "Not Implemented"),
_502(502, "Bad Gateway"),
_503(503, "Service Unavailable"),
_504(504, "Gateway Timeout"),
_505(505, "HTTP Version Not Supported"),
_506(506, "Variant Also Negotiates"),
_507(507, "Insufficient Storage"),
_508(508, "Loop Detected"),
_510(510, "Not Extended"),
_511(511, "Network Authentication Required"),
_599(599, "Network Connect Timeout Error");
static {
// Check values
for (Status s : values()) {
if (s.name().charAt(0) != '_') {
throw new IllegalStateException("Status code '" + s + "' need to start with underscore.");
}
}
}
private String description;
private int code;
Status(int code, String description) {
this.code = code;
this.description = description;
}
public static Status valueOf(int code) {
// Find status which matches code
for (Status status : values()) {
if (status.code == code) {
return status;
}
}
return null;
}
public String getDescription() {
return description;
}
public int getCode() {
return code;
}
}