summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2015-10-21 10:36:37 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2015-10-21 10:36:37 +0200
commitcf9b8fc1820bca714907b71812daa22641e2350d (patch)
treeba11492f0f0a1ed62105656ee4473cb1cd1ad75c /lib
parent26836d4c1770cf7b30ae1e95ee2027c861a925a4 (diff)
parente589226f58698dec4fdb95a555bd9c15e96faba5 (diff)
downloadnextcloud-server-cf9b8fc1820bca714907b71812daa22641e2350d.tar.gz
nextcloud-server-cf9b8fc1820bca714907b71812daa22641e2350d.zip
Merge pull request #18184 from owncloud/ocs-merge-headers
Merge headers of ocs results
Diffstat (limited to 'lib')
-rw-r--r--lib/private/api.php18
-rw-r--r--lib/private/ocs/result.php4
2 files changed, 14 insertions, 8 deletions
diff --git a/lib/private/api.php b/lib/private/api.php
index 10d58f2d9e6..6d7354c7193 100644
--- a/lib/private/api.php
+++ b/lib/private/api.php
@@ -231,7 +231,8 @@ class OC_API {
$picked = reset($shipped['failed']);
$code = $picked['response']->getStatusCode();
$meta = $picked['response']->getMeta();
- $response = new OC_OCS_Result($data, $code, $meta['message']);
+ $headers = $picked['response']->getHeaders();
+ $response = new OC_OCS_Result($data, $code, $meta['message'], $headers);
return $response;
} elseif(!empty($shipped['succeeded'])) {
$responses = array_merge($shipped['succeeded'], $thirdparty['succeeded']);
@@ -244,13 +245,16 @@ class OC_API {
$picked = reset($thirdparty['failed']);
$code = $picked['response']->getStatusCode();
$meta = $picked['response']->getMeta();
- $response = new OC_OCS_Result($data, $code, $meta['message']);
+ $headers = $picked['response']->getHeaders();
+ $response = new OC_OCS_Result($data, $code, $meta['message'], $headers);
return $response;
} else {
$responses = $thirdparty['succeeded'];
}
// Merge the successful responses
- $data = array();
+ $data = [];
+ $codes = [];
+ $header = [];
foreach($responses as $response) {
if($response['shipped']) {
@@ -258,8 +262,9 @@ class OC_API {
} else {
$data = array_merge_recursive($data, $response['response']->getData());
}
- $codes[] = array('code' => $response['response']->getStatusCode(),
- 'meta' => $response['response']->getMeta());
+ $header = array_merge_recursive($header, $response['response']->getHeaders());
+ $codes[] = ['code' => $response['response']->getStatusCode(),
+ 'meta' => $response['response']->getMeta()];
}
// Use any non 100 status codes
@@ -273,8 +278,7 @@ class OC_API {
}
}
- $result = new OC_OCS_Result($data, $statusCode, $statusMessage);
- return $result;
+ return new OC_OCS_Result($data, $statusCode, $statusMessage, $header);
}
/**
diff --git a/lib/private/ocs/result.php b/lib/private/ocs/result.php
index 916e25e45ae..2c3f676510c 100644
--- a/lib/private/ocs/result.php
+++ b/lib/private/ocs/result.php
@@ -51,8 +51,9 @@ class OC_OCS_Result{
* @param mixed $data the data to return
* @param int $code
* @param null|string $message
+ * @param array $headers
*/
- public function __construct($data=null, $code=100, $message=null) {
+ public function __construct($data = null, $code = 100, $message = null, $headers = []) {
if ($data === null) {
$this->data = array();
} elseif (!is_array($data)) {
@@ -62,6 +63,7 @@ class OC_OCS_Result{
}
$this->statusCode = $code;
$this->message = $message;
+ $this->headers = $headers;
}
/**