3 * GNU social - a federating social network
4 * Copyright (C) 2015, Free Software Foundation, Inc.
5 * Copyright (C) before that, StatusNet, Inc.
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 if (!defined('GNUSOCIAL') && !defined('STATUSNET')) { exit(1); }
23 abstract class AtompubAction extends ApiAuthAction
25 protected function prepare(array $args=array())
27 parent::prepare($args);
29 return $this->atompubPrepare();
32 protected function atompubPrepare() {
36 protected function handle()
40 switch ($_SERVER['REQUEST_METHOD']) {
51 $this->handleDelete();
54 // TRANS: Client exception thrown when using an unsupported HTTP method.
55 throw new ClientException(_('HTTP method not supported.'), 405);
61 protected function handleHead()
66 protected function handleGet()
68 throw new ClientException(_('HTTP method not supported.'), 405);
71 protected function handlePost()
73 throw new ClientException(_('HTTP method not supported.'), 405);
76 protected function handleDelete()
78 throw new ClientException(_('HTTP method not supported.'), 405);
81 function isReadOnly($args)
83 // GET/HEAD is readonly, POST and DELETE (etc?) are readwrite.
84 return in_array($_SERVER['REQUEST_METHOD'], array('GET', 'HEAD'));
87 function requiresAuth()
89 // GET/HEAD don't require auth, POST and DELETE (etc?) require it.
90 return !in_array($_SERVER['REQUEST_METHOD'], array('GET', 'HEAD'));