aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2015-08-06 00:01:56 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2015-08-13 10:45:25 +0200
commit1d219cf799b82babd0d31825e8d6fa03a20bf581 (patch)
treeb4f184f0156f34e481e065ee947f4643ad941067
parent55dc74bba48704cc2478530300aece9396b7b191 (diff)
downloadnextcloud-server-1d219cf799b82babd0d31825e8d6fa03a20bf581.tar.gz
nextcloud-server-1d219cf799b82babd0d31825e8d6fa03a20bf581.zip
With V2 we should ensure that the status codes are kept in sync
-rw-r--r--lib/private/api.php12
-rw-r--r--lib/private/ocs/result.php2
-rw-r--r--lib/public/appframework/http/ocsresponse.php2
3 files changed, 9 insertions, 7 deletions
diff --git a/lib/private/api.php b/lib/private/api.php
index fb2110471b2..3c599de25a9 100644
--- a/lib/private/api.php
+++ b/lib/private/api.php
@@ -354,15 +354,18 @@ class OC_API {
header($name . ': ' . $value);
}
+ $meta = $result->getMeta();
+ $data = $result->getData();
if (self::isV2()) {
$statusCode = self::mapStatusCodes($result->getStatusCode());
if (!is_null($statusCode)) {
+ $meta['statuscode'] = $statusCode;
OC_Response::setStatus($statusCode);
}
}
self::setContentType($format);
- $body = self::renderResult($result, $format);
+ $body = self::renderResult($format, $meta, $data);
echo $body;
}
@@ -452,15 +455,14 @@ class OC_API {
}
/**
- * @param OC_OCS_Result $result
* @param string $format
* @return string
*/
- public static function renderResult($result, $format) {
+ public static function renderResult($format, $meta, $data) {
$response = array(
'ocs' => array(
- 'meta' => $result->getMeta(),
- 'data' => $result->getData(),
+ 'meta' => $meta,
+ 'data' => $data,
),
);
if ($format == 'json') {
diff --git a/lib/private/ocs/result.php b/lib/private/ocs/result.php
index c4b0fbf33f3..42b6166b823 100644
--- a/lib/private/ocs/result.php
+++ b/lib/private/ocs/result.php
@@ -93,7 +93,7 @@ class OC_OCS_Result{
*/
public function getMeta() {
$meta = array();
- $meta['status'] = ($this->statusCode === 100) ? 'ok' : 'failure';
+ $meta['status'] = $this->succeeded() ? 'ok' : 'failure';
$meta['statuscode'] = $this->statusCode;
$meta['message'] = $this->message;
if(isset($this->items)) {
diff --git a/lib/public/appframework/http/ocsresponse.php b/lib/public/appframework/http/ocsresponse.php
index 2e788a52bb9..adbe33d7c3c 100644
--- a/lib/public/appframework/http/ocsresponse.php
+++ b/lib/public/appframework/http/ocsresponse.php
@@ -85,7 +85,7 @@ class OCSResponse extends Response {
$r->setTotalItems($this->itemscount);
$r->setItemsPerPage($this->itemsperpage);
- return \OC_API::renderResult($r, $this->format);
+ return \OC_API::renderResult($this->format, $r->getMeta(), $r->getData());
}