Permalink
Browse files

split content-type and get real mime type

Nowadays there could be content-types like “text/xml; charset=utf-8
which doesn’t match to ”text/xml” at all. This splits from ; and takes
first element and does the comparison using that instead.
  • Loading branch information...
1 parent e9254e5 commit 8d569263eac91ad9484b45acb3a6381759138f3c @Smarre committed Dec 19, 2012
Showing with 4 additions and 2 deletions.
  1. +4 −2 PEAR/REST.php
View
@@ -129,11 +129,13 @@ function retrieveData($url, $accept = false, $forcestring = false, $channel = fa
}
if (isset($headers['content-type'])) {
- switch ($headers['content-type']) {
+ $content_type = explode(";", $headers['content-type']);
+ $content_type = $content_type[0];
+ switch ($content_type) {
case 'text/xml' :
case 'application/xml' :
case 'text/plain' :
- if ($headers['content-type'] === 'text/plain') {
+ if ($content_type === 'text/plain') {
$check = substr($content, 0, 5);
if ($check !== '<?xml') {
break;

0 comments on commit 8d56926

Please sign in to comment.