Merge "Improve handling of uncommitted DB txns with "uncaught" exceptions"
[lhc/web/wiklou.git] / includes / libs / HttpStatus.php
1 <?php
2 /**
3 * List of HTTP status codes.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 */
22
23 /**
24 * @todo document
25 */
26 class HttpStatus {
27
28 /**
29 * Get the message associated with HTTP response code $code
30 *
31 * Replace OutputPage::getStatusMessage( $code )
32 *
33 * @param $code Integer: status code
34 * @return String or null: message or null if $code is not in the list of
35 * messages
36 */
37 public static function getMessage( $code ) {
38 static $statusMessage = array(
39 100 => 'Continue',
40 101 => 'Switching Protocols',
41 102 => 'Processing',
42 200 => 'OK',
43 201 => 'Created',
44 202 => 'Accepted',
45 203 => 'Non-Authoritative Information',
46 204 => 'No Content',
47 205 => 'Reset Content',
48 206 => 'Partial Content',
49 207 => 'Multi-Status',
50 300 => 'Multiple Choices',
51 301 => 'Moved Permanently',
52 302 => 'Found',
53 303 => 'See Other',
54 304 => 'Not Modified',
55 305 => 'Use Proxy',
56 307 => 'Temporary Redirect',
57 400 => 'Bad Request',
58 401 => 'Unauthorized',
59 402 => 'Payment Required',
60 403 => 'Forbidden',
61 404 => 'Not Found',
62 405 => 'Method Not Allowed',
63 406 => 'Not Acceptable',
64 407 => 'Proxy Authentication Required',
65 408 => 'Request Timeout',
66 409 => 'Conflict',
67 410 => 'Gone',
68 411 => 'Length Required',
69 412 => 'Precondition Failed',
70 413 => 'Request Entity Too Large',
71 414 => 'Request-URI Too Large',
72 415 => 'Unsupported Media Type',
73 416 => 'Request Range Not Satisfiable',
74 417 => 'Expectation Failed',
75 422 => 'Unprocessable Entity',
76 423 => 'Locked',
77 424 => 'Failed Dependency',
78 428 => 'Precondition Required',
79 429 => 'Too Many Requests',
80 431 => 'Request Header Fields Too Large',
81 500 => 'Internal Server Error',
82 501 => 'Not Implemented',
83 502 => 'Bad Gateway',
84 503 => 'Service Unavailable',
85 504 => 'Gateway Timeout',
86 505 => 'HTTP Version Not Supported',
87 507 => 'Insufficient Storage',
88 511 => 'Network Authentication Required',
89 );
90 return isset( $statusMessage[$code] ) ? $statusMessage[$code] : null;
91 }
92
93 }