summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/public/appframework/controller.php44
-rw-r--r--tests/lib/appframework/controller/ControllerTest.php9
2 files changed, 31 insertions, 22 deletions
diff --git a/lib/public/appframework/controller.php b/lib/public/appframework/controller.php
index b3bff5e05f5..b22eb73343a 100644
--- a/lib/public/appframework/controller.php
+++ b/lib/public/appframework/controller.php
@@ -70,28 +70,28 @@ abstract class Controller {
}
- /**
- * Parses an HTTP accept header and returns the supported responder type
- * @param string $acceptHeader
- * @return string the responder type
- */
- public function getResponderByHTTPHeader($acceptHeader) {
- $headers = explode(',', $acceptHeader);
-
- // return the first matching responder
- foreach ($headers as $header) {
- $header = trim($header);
-
- $responder = str_replace('application/', '', $header);
-
- if (array_key_exists($responder, $this->responders)) {
- return $responder;
- }
- }
-
- // no matching header defaults to json
- return 'json';
- }
+ /**
+ * Parses an HTTP accept header and returns the supported responder type
+ * @param string $acceptHeader
+ * @return string the responder type
+ */
+ public function getResponderByHTTPHeader($acceptHeader) {
+ $headers = explode(',', $acceptHeader);
+
+ // return the first matching responder
+ foreach ($headers as $header) {
+ $header = strtolower(trim($header));
+
+ $responder = str_replace('application/', '', $header);
+
+ if (array_key_exists($responder, $this->responders)) {
+ return $responder;
+ }
+ }
+
+ // no matching header defaults to json
+ return 'json';
+ }
/**
diff --git a/tests/lib/appframework/controller/ControllerTest.php b/tests/lib/appframework/controller/ControllerTest.php
index 1a09925ef69..e97ec548939 100644
--- a/tests/lib/appframework/controller/ControllerTest.php
+++ b/tests/lib/appframework/controller/ControllerTest.php
@@ -185,4 +185,13 @@ class ControllerTest extends \PHPUnit_Framework_TestCase {
}
+ public function testResponderAcceptHeaderParsedUpperCase() {
+ $responder = $this->controller->getResponderByHTTPHeader(
+ '*/*, apPlication/ToM, application/json'
+ );
+
+ $this->assertEquals('tom', $responder);
+ }
+
+
}