forked from rspieker/konsolidate_breed
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatus.class.php
175 lines (163 loc) · 3.14 KB
/
status.class.php
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<?php
class BreedStatus extends Konsolidate
{
public function send($status, $message='', $useHTTP=true)
{
if (!headers_sent())
{
header(($useHTTP ? 'HTTP/1.0' : 'Status:') . ' ' . $status . ' ' . (!empty($message) ? $message : $this->getMessage($status)));
return true;
}
return false;
}
public function getMessage($status)
{
$message = 'Unknown';
switch($status)
{
/* 1xx - INFORMATIONAL */
case 100:
$message = 'Continue';
break;
case 101:
$message = 'Switching Protocols';
break;
/* 2xx - SUCCESSFUL */
case 200:
$message = 'OK';
break;
case 201:
$message = 'Created';
break;
case 202:
$message = 'Accepted';
break;
case 203:
$message = 'Non-Authoritative Information';
break;
case 204:
$message = 'No Content';
break;
case 205:
$message = 'Reset Content';
break;
case 206:
$message = 'Partial Content';
break;
case 207:
$message = 'Multi-Status';
break;
/* 3xx - REDIRECTION */
case 300:
$message = 'Multiple Choices';
break;
case 301:
$message = 'Moved Permanently';
break;
case 302:
$message = 'Found';
break;
case 303:
$message = 'See Other';
break;
case 304:
$message = 'Not Modified';
break;
case 305:
$message = 'Use Proxy';
break;
case 306:
$message = '(Reserved)';
case 307:
$message = 'Temporary Redirect';
break;
/* 4xx - CLIENT ERROR */
case 400:
$message = 'Bad Request';
break;
case 401:
$message = 'Unauthorized';
break;
case 402:
$message = 'Payment Required';
break;
case 403:
$message = 'Forbidden';
break;
case 404:
$message = 'Not Found';
break;
case 405:
$message = 'Method Not Allowed';
break;
case 406:
$message = 'Not Acceptable';
break;
case 407:
$message = 'Proxy Authentication';
break;
case 408:
$message = 'Request Timeout';
break;
case 409:
$message = 'Conflict';
break;
case 410:
$message = 'Gone';
break;
case 411:
$message = 'Length Required';
break;
case 412:
$message = 'Precondition Failed';
break;
case 413:
$message = 'Request Entity Too Large';
break;
case 414:
$message = 'Request-URI Too Long';
break;
case 415:
$message = 'Unsupported Media Type';
break;
case 416:
$message = 'Requested Range Not Satisfiable';
break;
case 417:
$message = 'Expectation Failed';
break;
case 422:
$message = 'Unprocessable Entity';
break;
case 423:
$message = 'Locked';
break;
case 424:
$message = 'Failed Dependency';
break;
/* 5xx - SERVER ERROR */
case 500:
$message = 'Internal Server Error';
break;
case 501:
$message = 'Not Implemented';
break;
case 502:
$message = 'Bad Gateway';
break;
case 503:
$message = 'Service Unavailable';
break;
case 504:
$message = 'Gateway Timeout';
break;
case 505:
$message = 'HTTP Version Not Supported';
break;
case 507:
$message = 'Insufficient Storage';
break;
}
return $message;
}
}