This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page. class


Internet media type used in HTTP headers


The MediaType class represents an internet media type, as defined in RFC 7231 — Media Type, section The MediaType class also represents the contents of a Content-Type field or an Accept field.


obj =,paramName,paramValue) creates a MediaType object given by type, with additional options specified by one or more paramName,paramValue pair arguments. You can specify several paramName,paramValue pair arguments in any order as paramName1,paramValue1,...,paramNameN,paramValueN.

obj = parses text to create a media type. Quotes and escape characters within the values of parameters are removed. This constructor does not prevent creating a MediaType object with duplicate parameter names.

Input Arguments

expand all

Media type, specified as a string. The type must have the syntax of type/subtype.

Parameter name, specified as a nonempty string.

Parameter value, specified as a nonempty string or type acceptable to the string function. The string function adds quotes and escapes as needed. Do not include quotation or escape characters within paramValue.

Media type, specified as a string.


expand all

Primary type, specified as a nonempty string.

Subtype, specified as a nonempty string.

Parameters, specified as an nx2 string matrix. Parameters(i,1) is the name of the ith parameter and Parameters(i,2) is its value. Use the setParameter method to add or change parameter values. To reorder or remove parameters, construct a new MediaType object with the parameters you want to use from an existing MediaType object.



Media type portion, specified as a object. MediaInfo contains the MediaType object without the parameters at or following the first q parameter.



Weight parameter q, specified as double. If there is no q parameter, then Weight is empty. If the parameter cannot be converted to a double, then Weight is NaN. If you set this property, it must have a value in the range 0–1. Setting this value modifies the final q parameter in the object or adds one to the end of the parameter list.




getParameterValue of media type parameter
setParameterSet value of media type parameter

These methods implement the equivalent MATLAB® functionality for this class.

eq and isequal

Compare two MediaType objects


MediaType as character vector


MediaType as string

Introduced in R2016b

Was this topic helpful?