Skip to content

Commit

Permalink
Fixed _detect_input_format
Browse files Browse the repository at this point in the history
  • Loading branch information
softwarespot committed Apr 3, 2016
1 parent 6e675db commit 91a8bff
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions application/libraries/REST_Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
Expand Down

0 comments on commit 91a8bff

Please sign in to comment.