9 * @author Evan Prodromou <evan@status.net>
10 * @author Zach Copley <zach@status.net>
11 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
12 * @link http://status.net/
14 * StatusNet - the distributed open-source microblogging tool
15 * Copyright (C) 2008-2010 StatusNet, Inc.
17 * This program is free software: you can redistribute it and/or modify
18 * it under the terms of the GNU Affero General Public License as published by
19 * the Free Software Foundation, either version 3 of the License, or
20 * (at your option) any later version.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU Affero General Public License for more details.
27 * You should have received a copy of the GNU Affero General Public License
28 * along with this program. If not, see <http://www.gnu.org/licenses/>.
31 if (!defined('GNUSOCIAL')) { exit(1); }
34 * Class for displaying HTTP client errors
38 * @author Zach Copley <zach@status.net>
39 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
40 * @link http://status.net/
42 class ClientErrorAction extends ErrorAction
44 static $status = array(400 => 'Bad Request',
45 401 => 'Unauthorized',
46 402 => 'Payment Required',
49 405 => 'Method Not Allowed',
50 406 => 'Not Acceptable',
51 407 => 'Proxy Authentication Required',
52 408 => 'Request Timeout',
55 411 => 'Length Required',
56 412 => 'Precondition Failed',
57 413 => 'Request Entity Too Large',
58 414 => 'Request-URI Too Long',
59 415 => 'Unsupported Media Type',
60 416 => 'Requested Range Not Satisfiable',
61 417 => 'Expectation Failed');
63 function __construct($message='Error', $code=400)
65 parent::__construct($message, $code);
68 if (!$this->code || $this->code < 400 || $this->code > 499) {
69 $this->code = $this->default;
71 if (!$this->message) {
72 $this->message = "Client Error $this->code";
77 * To specify additional HTTP headers for the action
81 function extraHeaders()
83 $status_string = @self::$status[$this->code];
84 header('HTTP/1.1 '.$this->code.' '.$status_string);
95 return @self::$status[$this->code];