From 91a8bff948e52de905dc2a7d21f18e1b5d344a22 Mon Sep 17 00:00:00 2001 From: softwarespot Date: Sun, 21 Feb 2016 12:44:52 +0200 Subject: [PATCH] Fixed _detect_input_format --- application/libraries/REST_Controller.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/application/libraries/REST_Controller.php b/application/libraries/REST_Controller.php index 04fbf1eb..6f650a2b 100644 --- a/application/libraries/REST_Controller.php +++ b/application/libraries/REST_Controller.php @@ -825,20 +825,20 @@ protected function _detect_input_format() if (empty($content_type) === FALSE) { - // Check all formats against the HTTP_ACCEPT header - foreach ($this->_supported_formats as $key => $value) - { - // $key = format e.g. csv - // $value = mime type e.g. application/csv + // If a semi-colon exists in the string, then explode by ; and get the value of where + // the current array pointer resides. This will generally be the first element of the array + $content_type = (strpos($content_type, ';') !== FALSE ? current(explode(';', $content_type)) : $content_type); - // If a semi-colon exists in the string, then explode by ; and get the value of where - // the current array pointer resides. This will generally be the first element of the array - $content_type = (strpos($content_type, ';') !== FALSE ? current(explode(';', $content_type)) : $content_type); + // Check all formats against the CONTENT-TYPE header + foreach ($this->_supported_formats as $type => $mime) + { + // $type = format e.g. csv + // $mime = mime type e.g. application/csv // If both the mime types match, then return the format - if ($content_type === $value) + if ($content_type === $mime) { - return $key; + return $type; } } }