summaryrefslogtreecommitdiffstats
path: root/lib/private/api.php
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2014-03-12 00:35:19 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2014-03-12 00:35:19 +0100
commit743addd1e317c760e8b1e4ad7dc149476e4ad282 (patch)
tree2f0b4d3f9c922153408d9919a8a52d14aec8edbf /lib/private/api.php
parent364e1f852fe8640d7d6fa149f784a0d2d1de0a57 (diff)
downloadnextcloud-server-743addd1e317c760e8b1e4ad7dc149476e4ad282.tar.gz
nextcloud-server-743addd1e317c760e8b1e4ad7dc149476e4ad282.zip
set content-type on ocs exceptions
Diffstat (limited to 'lib/private/api.php')
-rw-r--r--lib/private/api.php33
1 files changed, 30 insertions, 3 deletions
diff --git a/lib/private/api.php b/lib/private/api.php
index 1537cc11dd0..ccaccda97be 100644
--- a/lib/private/api.php
+++ b/lib/private/api.php
@@ -116,9 +116,7 @@ class OC_API {
);
}
$response = self::mergeResponses($responses);
- $formats = array('json', 'xml');
-
- $format = !empty($_GET['format']) && in_array($_GET['format'], $formats) ? $_GET['format'] : 'xml';
+ $format = self::requestedFormat();
if (self::$logoutRequired) {
OC_User::logout();
}
@@ -350,4 +348,33 @@ class OC_API {
}
}
+ /**
+ * @return string
+ */
+ public static function requestedFormat() {
+ $formats = array('json', 'xml');
+
+ $format = !empty($_GET['format']) && in_array($_GET['format'], $formats) ? $_GET['format'] : 'xml';
+ return $format;
+ }
+
+ /**
+ * Based on the requested format the response content type is set
+ */
+ public static function setOcsContentType() {
+ $format = \OC_API::requestedFormat();
+ if ($format === 'xml') {
+ header('Content-type: text/xml; charset=UTF-8');
+ return;
+ }
+
+ if ($format === 'json') {
+ header('Content-Type: application/json; charset=utf-8');
+ return;
+ }
+
+ header('Content-Type: application/octet-stream; charset=utf-8');
+ }
+
+
}