public static function EasyRdf_Format::getHttpAcceptHeader

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.

Parameters

array $extraTypes extra MIME types to add:

Return value

string list of supported MIME types

2 calls to EasyRdf_Format::getHttpAcceptHeader()
EasyRdf_Graph::load in drupal/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Graph.php
Load RDF data into the graph from a URI.
EasyRdf_Sparql_Client::query in drupal/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Sparql/Client.php
Make a query to the SPARQL endpoint

File

drupal/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Format.php, line 93

Class

EasyRdf_Format
Class the represents an RDF file format.

Code

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;
}