Preferences that need to be updated.
A copy of the the preferences with the necessary updates.
Finds the type from the given types that has the best match with the given preferences, based on the calculated weight.
Types for which we want to find the best match.
Preferences to match the types against.
A ValuePreference containing the best match and the corresponding weight. Undefined if there is no match.
For a media type converter that can generate the given types, this function tries to find the type that best matches the given preferences.
This function combines several other conversion utility functions to determine what output a converter should generate: it cleans the preferences with cleanPreferences to support empty preferences and to prevent the accidental generation of internal types, after which the best match gets found based on the weights.
Media types that can be converted to.
Preferences for output type.
The best match. Undefined if there is no match.
Tries to match the given type to the given preferences. In case there are multiple matches the most specific one will be chosen as per RFC 7231.
Type for which the matching weight is needed.
Preferences to match the type to.
The corresponding weight from the preferences or 0 if there is no match.
Measures the weights for all the given types when matched against the given preferences. Results will be sorted by weight. Weights of 0 indicate that no match is possible.
Types for which we want to calculate the weights.
Preferences to match the types against.
An array with a ValuePreference object for every input type, sorted by calculated weight.
Checks if the given content type is an internal content type such as internal/quads.
Response will be false
if the input type is undefined.
Do not use this for media ranges.
Type to check.
Checks if the given type matches the given preferences.
Type to match.
Preferences to match against.
Checks if the given two media types/ranges match each other. Takes wildcards into account.
Media type to match.
Media type to match.
True if the media type patterns can match each other.
Cleans incoming preferences to prevent unwanted behaviour. Makes sure internal types have weight 0, unless specifically requested in the preferences, and interprets empty preferences as accepting everything.