From 842e5603a1754075d3bf95b4cc6dc550b11e5bd3 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 27 Jun 2018 10:26:22 +0200 Subject: [PATCH] Request: Introduce method extractMediaType refs #3484 --- library/Icinga/Web/Request.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/library/Icinga/Web/Request.php b/library/Icinga/Web/Request.php index 88fb729cb..7fd4664fa 100644 --- a/library/Icinga/Web/Request.php +++ b/library/Icinga/Web/Request.php @@ -128,4 +128,18 @@ class Request extends Zend_Controller_Request_Http ? Json::decode(file_get_contents('php://input'), true) : parent::getPost($key, $default); } + + /** + * Extract and return the media type from the given header value + * + * @param string $headerValue + * + * @return string + */ + protected function extractMediaType($headerValue) + { + // Pretty basic and does not care about parameters + $parts = explode(';', $headerValue, 2); + return strtolower(trim($parts[0])); + } }