summaryrefslogtreecommitdiff
path: root/lib/apiaction.php
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2010-10-13 15:18:32 -0400
committerEvan Prodromou <evan@status.net>2010-10-13 15:18:32 -0400
commitddb60a8191de23fc11f6711954575ac7b6f49998 (patch)
tree46532e67a29fdd46a1877a80c253445c09e98a67 /lib/apiaction.php
parentf11c1c77cab7d7310ec0d2c17bc6f35c491f2871 (diff)
parent6c77d86b7f39c35eac0fcc3f13c0beba3e694318 (diff)
Merge remote branch 'gitorious/0.9.x' into 0.9.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 0ebf88282..afba8ab63 100644
--- a/lib/apiaction.php
+++ b/lib/apiaction.php
@@ -1244,23 +1244,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);
}