|
1
|
|
|
<?php |
|
2
|
|
|
namespace nebula\application\response\provider; |
|
3
|
|
|
|
|
4
|
|
|
/** |
|
5
|
|
|
* 响应状态 |
|
6
|
|
|
*/ |
|
7
|
|
|
class Status |
|
8
|
|
|
{ |
|
9
|
|
|
public static $statusTexts = [ |
|
10
|
|
|
100 => 'Continue', |
|
11
|
|
|
101 => 'Switching Protocols', |
|
12
|
|
|
102 => 'Processing', // RFC2518 |
|
13
|
|
|
103 => 'Early Hints', |
|
14
|
|
|
200 => 'OK', |
|
15
|
|
|
201 => 'Created', |
|
16
|
|
|
202 => 'Accepted', |
|
17
|
|
|
203 => 'Non-Authoritative Information', |
|
18
|
|
|
204 => 'No Content', |
|
19
|
|
|
205 => 'Reset Content', |
|
20
|
|
|
206 => 'Partial Content', |
|
21
|
|
|
207 => 'Multi-Status', // RFC4918 |
|
22
|
|
|
208 => 'Already Reported', // RFC5842 |
|
23
|
|
|
226 => 'IM Used', // RFC3229 |
|
24
|
|
|
300 => 'Multiple Choices', |
|
25
|
|
|
301 => 'Moved Permanently', |
|
26
|
|
|
302 => 'Found', |
|
27
|
|
|
303 => 'See Other', |
|
28
|
|
|
304 => 'Not Modified', |
|
29
|
|
|
305 => 'Use Proxy', |
|
30
|
|
|
307 => 'Temporary Redirect', |
|
31
|
|
|
308 => 'Permanent Redirect', // RFC7238 |
|
32
|
|
|
400 => 'Bad Request', |
|
33
|
|
|
401 => 'Unauthorized', |
|
34
|
|
|
402 => 'Payment Required', |
|
35
|
|
|
403 => 'Forbidden', |
|
36
|
|
|
404 => 'Not Found', |
|
37
|
|
|
405 => 'Method Not Allowed', |
|
38
|
|
|
406 => 'Not Acceptable', |
|
39
|
|
|
407 => 'Proxy Authentication Required', |
|
40
|
|
|
408 => 'Request Timeout', |
|
41
|
|
|
409 => 'Conflict', |
|
42
|
|
|
410 => 'Gone', |
|
43
|
|
|
411 => 'Length Required', |
|
44
|
|
|
412 => 'Precondition Failed', |
|
45
|
|
|
413 => 'Payload Too Large', |
|
46
|
|
|
414 => 'URI Too Long', |
|
47
|
|
|
415 => 'Unsupported Media Type', |
|
48
|
|
|
416 => 'Range Not Satisfiable', |
|
49
|
|
|
417 => 'Expectation Failed', |
|
50
|
|
|
418 => 'I\'m a teapot', // RFC2324 |
|
51
|
|
|
421 => 'Misdirected Request', // RFC7540 |
|
52
|
|
|
422 => 'Unprocessable Entity', // RFC4918 |
|
53
|
|
|
423 => 'Locked', // RFC4918 |
|
54
|
|
|
424 => 'Failed Dependency', // RFC4918 |
|
55
|
|
|
425 => 'Too Early', // RFC-ietf-httpbis-replay-04 |
|
56
|
|
|
426 => 'Upgrade Required', // RFC2817 |
|
57
|
|
|
428 => 'Precondition Required', // RFC6585 |
|
58
|
|
|
429 => 'Too Many Requests', // RFC6585 |
|
59
|
|
|
431 => 'Request Header Fields Too Large', // RFC6585 |
|
60
|
|
|
451 => 'Unavailable For Legal Reasons', // RFC7725 |
|
61
|
|
|
500 => 'Internal Server Error', |
|
62
|
|
|
501 => 'Not Implemented', |
|
63
|
|
|
502 => 'Bad Gateway', |
|
64
|
|
|
503 => 'Service Unavailable', |
|
65
|
|
|
504 => 'Gateway Timeout', |
|
66
|
|
|
505 => 'HTTP Version Not Supported', |
|
67
|
|
|
506 => 'Variant Also Negotiates', // RFC2295 |
|
68
|
|
|
507 => 'Insufficient Storage', // RFC4918 |
|
69
|
|
|
508 => 'Loop Detected', // RFC5842 |
|
70
|
|
|
510 => 'Not Extended', // RFC2774 |
|
71
|
|
|
511 => 'Network Authentication Required', // RFC6585 |
|
72
|
|
|
]; |
|
73
|
|
|
|
|
74
|
|
|
const HTTP_CONTINUE = 100; |
|
75
|
|
|
const HTTP_SWITCHING_PROTOCOLS = 101; |
|
76
|
|
|
const HTTP_PROCESSING = 102; // RFC2518 |
|
77
|
|
|
const HTTP_EARLY_HINTS = 103; // RFC8297 |
|
78
|
|
|
const HTTP_OK = 200; |
|
79
|
|
|
const HTTP_CREATED = 201; |
|
80
|
|
|
const HTTP_ACCEPTED = 202; |
|
81
|
|
|
const HTTP_NON_AUTHORITATIVE_INFORMATION = 203; |
|
82
|
|
|
const HTTP_NO_CONTENT = 204; |
|
83
|
|
|
const HTTP_RESET_CONTENT = 205; |
|
84
|
|
|
const HTTP_PARTIAL_CONTENT = 206; |
|
85
|
|
|
const HTTP_MULTI_STATUS = 207; // RFC4918 |
|
86
|
|
|
const HTTP_ALREADY_REPORTED = 208; // RFC5842 |
|
87
|
|
|
const HTTP_IM_USED = 226; // RFC3229 |
|
88
|
|
|
const HTTP_MULTIPLE_CHOICES = 300; |
|
89
|
|
|
const HTTP_MOVED_PERMANENTLY = 301; |
|
90
|
|
|
const HTTP_FOUND = 302; |
|
91
|
|
|
const HTTP_SEE_OTHER = 303; |
|
92
|
|
|
const HTTP_NOT_MODIFIED = 304; |
|
93
|
|
|
const HTTP_USE_PROXY = 305; |
|
94
|
|
|
const HTTP_RESERVED = 306; |
|
95
|
|
|
const HTTP_TEMPORARY_REDIRECT = 307; |
|
96
|
|
|
const HTTP_PERMANENTLY_REDIRECT = 308; // RFC7238 |
|
97
|
|
|
const HTTP_BAD_REQUEST = 400; |
|
98
|
|
|
const HTTP_UNAUTHORIZED = 401; |
|
99
|
|
|
const HTTP_PAYMENT_REQUIRED = 402; |
|
100
|
|
|
const HTTP_FORBIDDEN = 403; |
|
101
|
|
|
const HTTP_NOT_FOUND = 404; |
|
102
|
|
|
const HTTP_METHOD_NOT_ALLOWED = 405; |
|
103
|
|
|
const HTTP_NOT_ACCEPTABLE = 406; |
|
104
|
|
|
const HTTP_PROXY_AUTHENTICATION_REQUIRED = 407; |
|
105
|
|
|
const HTTP_REQUEST_TIMEOUT = 408; |
|
106
|
|
|
const HTTP_CONFLICT = 409; |
|
107
|
|
|
const HTTP_GONE = 410; |
|
108
|
|
|
const HTTP_LENGTH_REQUIRED = 411; |
|
109
|
|
|
const HTTP_PRECONDITION_FAILED = 412; |
|
110
|
|
|
const HTTP_REQUEST_ENTITY_TOO_LARGE = 413; |
|
111
|
|
|
const HTTP_REQUEST_URI_TOO_LONG = 414; |
|
112
|
|
|
const HTTP_UNSUPPORTED_MEDIA_TYPE = 415; |
|
113
|
|
|
const HTTP_REQUESTED_RANGE_NOT_SATISFIABLE = 416; |
|
114
|
|
|
const HTTP_EXPECTATION_FAILED = 417; |
|
115
|
|
|
const HTTP_I_AM_A_TEAPOT = 418; // RFC2324 |
|
116
|
|
|
const HTTP_MISDIRECTED_REQUEST = 421; // RFC7540 |
|
117
|
|
|
const HTTP_UNPROCESSABLE_ENTITY = 422; // RFC4918 |
|
118
|
|
|
const HTTP_LOCKED = 423; // RFC4918 |
|
119
|
|
|
const HTTP_FAILED_DEPENDENCY = 424; // RFC4918 |
|
120
|
|
|
|
|
121
|
|
|
/** |
|
122
|
|
|
* @deprecated |
|
123
|
|
|
*/ |
|
124
|
|
|
const HTTP_RESERVED_FOR_WEBDAV_ADVANCED_COLLECTIONS_EXPIRED_PROPOSAL = 425; // RFC2817 |
|
125
|
|
|
const HTTP_TOO_EARLY = 425; // RFC-ietf-httpbis-replay-04 |
|
126
|
|
|
const HTTP_UPGRADE_REQUIRED = 426; // RFC2817 |
|
127
|
|
|
const HTTP_PRECONDITION_REQUIRED = 428; // RFC6585 |
|
128
|
|
|
const HTTP_TOO_MANY_REQUESTS = 429; // RFC6585 |
|
129
|
|
|
const HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE = 431; // RFC6585 |
|
130
|
|
|
const HTTP_UNAVAILABLE_FOR_LEGAL_REASONS = 451; |
|
131
|
|
|
const HTTP_INTERNAL_SERVER_ERROR = 500; |
|
132
|
|
|
const HTTP_NOT_IMPLEMENTED = 501; |
|
133
|
|
|
const HTTP_BAD_GATEWAY = 502; |
|
134
|
|
|
const HTTP_SERVICE_UNAVAILABLE = 503; |
|
135
|
|
|
const HTTP_GATEWAY_TIMEOUT = 504; |
|
136
|
|
|
const HTTP_VERSION_NOT_SUPPORTED = 505; |
|
137
|
|
|
const HTTP_VARIANT_ALSO_NEGOTIATES_EXPERIMENTAL = 506; // RFC2295 |
|
138
|
|
|
const HTTP_INSUFFICIENT_STORAGE = 507; // RFC4918 |
|
139
|
|
|
const HTTP_LOOP_DETECTED = 508; // RFC5842 |
|
140
|
|
|
const HTTP_NOT_EXTENDED = 510; // RFC2774 |
|
141
|
|
|
const HTTP_NETWORK_AUTHENTICATION_REQUIRED = 511; |
|
142
|
|
|
|
|
143
|
|
|
/** |
|
144
|
|
|
* 将状态码转换成状态字符串 |
|
145
|
|
|
* |
|
146
|
|
|
* @param string $code |
|
147
|
|
|
* @return string |
|
148
|
|
|
*/ |
|
149
|
|
|
public static function toText(string $code):string { |
|
150
|
|
|
return static::$statusTexts[$code] ?? ''; |
|
151
|
|
|
} |
|
152
|
|
|
} |
|
153
|
|
|
|