10 * @author Evan Prodromou <evan@status.net>
11 * @author Zach Copley <zach@status.net>
12 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
13 * @link http://status.net/
15 * StatusNet - the distributed open-source microblogging tool
16 * Copyright (C) 2008, 2009, StatusNet, Inc.
18 * This program is free software: you can redistribute it and/or modify
19 * it under the terms of the GNU Affero General Public License as published by
20 * the Free Software Foundation, either version 3 of the License, or
21 * (at your option) any later version.
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU Affero General Public License for more details.
28 * You should have received a copy of the GNU Affero General Public License
29 * along with this program. If not, see <http://www.gnu.org/licenses/>.
32 if (!defined('STATUSNET') && !defined('LACONICA')) {
36 require_once INSTALLDIR.'/lib/error.php';
39 * Class for displaying HTTP client errors
43 * @author Zach Copley <zach@status.net>
44 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
45 * @link http://status.net/
47 class ClientErrorAction extends ErrorAction
49 static $status = array(400 => 'Bad Request',
50 401 => 'Unauthorized',
51 402 => 'Payment Required',
54 405 => 'Method Not Allowed',
55 406 => 'Not Acceptable',
56 407 => 'Proxy Authentication Required',
57 408 => 'Request Timeout',
60 411 => 'Length Required',
61 412 => 'Precondition Failed',
62 413 => 'Request Entity Too Large',
63 414 => 'Request-URI Too Long',
64 415 => 'Unsupported Media Type',
65 416 => 'Requested Range Not Satisfiable',
66 417 => 'Expectation Failed');
68 function __construct($message='Error', $code=400)
70 parent::__construct($message, $code);
74 // XXX: Should these error actions even be invokable via URI?
76 function handle($args)
78 parent::handle($args);
80 $this->code = $this->trimmed('code');
82 if (!$this->code || $code < 400 || $code > 499) {
83 $this->code = $this->default;
86 $this->message = $this->trimmed('message');
88 if (!$this->message) {
89 $this->message = "Client Error $this->code";