Generates an HTTP Accept header string
The string will contain all of the MIME Types that we are able to parse.
It is also possible to specify additional MIME types in the form array('text/plain' => 0.5) where 0.5 is the q value for that type. The types are sorted by q value before constructing the string.
array $extraTypes extra MIME types to add:
string list of supported MIME types
public static function getHttpAcceptHeader($extraTypes = array()) {
$accept = $extraTypes;
foreach (self::$formats as $format) {
if ($format->parserClass and count($format->mimeTypes) > 0) {
$accept = array_merge($accept, $format->mimeTypes);
}
}
arsort($accept, SORT_NUMERIC);
$acceptStr = '';
foreach ($accept as $type => $q) {
if ($acceptStr) {
$acceptStr .= ',';
}
if ($q == 1.0) {
$acceptStr .= $type;
}
else {
$acceptStr .= sprintf("%s;q=%1.1f", $type, $q);
}
}
return $acceptStr;
}