Mimetype was not recognized if longer than bare mime

This commit is contained in:
Mikael Nordfeldth 2017-08-05 09:46:14 +02:00
parent 6938d26524
commit 945920f24d
2 changed files with 3 additions and 3 deletions

View File

@ -2060,7 +2060,7 @@ function common_bare_mime($mimetype)
if ($semicolon = mb_strpos($mimetype, ';')) {
$mimetype = mb_substr($mimetype, 0, $semicolon);
}
return $mimetype;
return trim($mimetype);
}
function common_mime_type_match($type, $avail)

View File

@ -124,7 +124,7 @@ class Discovery
throw new Exception('Unexpected HTTP status code.');
}
switch ($response->getHeader('content-type')) {
switch (common_bare_mime($response->getHeader('content-type'))) {
case self::JRD_MIMETYPE_OLD:
case self::JRD_MIMETYPE:
$type = 'json';
@ -134,7 +134,7 @@ class Discovery
break;
default:
// fall back to letting XML_XRD auto-detect
common_debug('No recognized content-type header for resource descriptor body.');
common_debug('No recognized content-type header for resource descriptor body on '._ve($xrd_uri));
$type = null;
}
$xrd->loadString($response->getBody(), $type);