You are here

public static function EasyRdf_Format::getHttpAcceptHeader in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/easyrdf/easyrdf/lib/EasyRdf/Format.php \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 vendor/easyrdf/easyrdf/lib/EasyRdf/Graph.php
Load RDF data into the graph from a URI.
EasyRdf_Sparql_Client::request in vendor/easyrdf/easyrdf/lib/EasyRdf/Sparql/Client.php

File

vendor/easyrdf/easyrdf/lib/EasyRdf/Format.php, line 92

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