MediaWiki master
Wikimedia\Http\HttpAcceptParser Class Reference

Public Member Functions

 parseAccept ( $accept)
 Parse media types from an Accept header and sort them by q-factor.
 
 parseWeights ( $rawHeader)
 Parses an HTTP header into a weight map, that is an associative array mapping values to their respective weights.
 

Detailed Description

Definition at line 13 of file HttpAcceptParser.php.

Member Function Documentation

◆ parseAccept()

Wikimedia\Http\HttpAcceptParser::parseAccept ( $accept)

Parse media types from an Accept header and sort them by q-factor.

Note that his was mostly ported from, https://github.com/arlolra/negotiator/blob/full-parse-access/lib/mediaType.js

Parameters
string$accept
Returns
array[]
  • type: (string)
  • subtype: (string)
  • q: (float) q-factor weighting
  • i: (int) index
  • params: (array)

Definition at line 29 of file HttpAcceptParser.php.

References $matches, and $params.

◆ parseWeights()

Wikimedia\Http\HttpAcceptParser::parseWeights ( $rawHeader)

Parses an HTTP header into a weight map, that is an associative array mapping values to their respective weights.

Any header name preceding weight spec is ignored for convenience.

Note that type parameters and accept extension like the "level" parameter are not supported, weights are derived from "q" values only.

See RFC 7231 section 5.3.2 for details.

Parameters
string$rawHeader
Returns
array

Definition at line 93 of file HttpAcceptParser.php.


The documentation for this class was generated from the following file: