summaryrefslogtreecommitdiff
path: root/lib/apiaction.php
diff options
context:
space:
mode:
authorCraig Andrews <candrews@integralblue.com>2010-10-14 15:27:17 -0400
committerCraig Andrews <candrews@integralblue.com>2010-10-14 15:27:17 -0400
commit0721d8d3e257709d27994eb4ab4bbe60abc93e2e (patch)
tree58cb9e3b5f8df089353617b498c340ad9276519b /lib/apiaction.php
parentf79dbaf9a76c10969dbc45fd43a0bb26f5f64ed4 (diff)
parentfc6711327bcb2319139171ad3353603753f13eaa (diff)
Merge remote branch 'statusnet/0.9.x' into 1.0.x
Diffstat (limited to 'lib/apiaction.php')
-rw-r--r--lib/apiaction.php16
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/apiaction.php b/lib/apiaction.php
index d8249055a..fbc3a1451 100644
--- a/lib/apiaction.php
+++ b/lib/apiaction.php
@@ -1246,23 +1246,29 @@ class ApiAction extends Action
// Do not emit error header for JSONP
if (!isset($this->callback)) {
- header('HTTP/1.1 '.$code.' '.$status_string);
+ header('HTTP/1.1 ' . $code . ' ' . $status_string);
}
- if ($format == 'xml') {
+ switch($format) {
+ case 'xml':
$this->initDocument('xml');
$this->elementStart('hash');
$this->element('error', null, $msg);
$this->element('request', null, $_SERVER['REQUEST_URI']);
$this->elementEnd('hash');
$this->endDocument('xml');
- } elseif ($format == 'json'){
+ break;
+ case 'json':
$this->initDocument('json');
$error_array = array('error' => $msg, 'request' => $_SERVER['REQUEST_URI']);
print(json_encode($error_array));
$this->endDocument('json');
- } else {
-
+ break;
+ case 'text':
+ header('Content-Type: text/plain; charset=utf-8');
+ print $msg;
+ break;
+ default:
// If user didn't request a useful format, throw a regular client error
throw new ClientException($msg, $code);
}