matlab.net.http.field.ContentTypeField - HTTP Content-Type header field - MATLAB (original) (raw)
Main Content
Namespace: matlab.net.http.field
Superclasses: matlab.net.http.HeaderField, matlab.net.http.field.MediaRangeField
HTTP Content-Type header field
Description
A ContentTypeField
object is an HTTP header field in a request or response message. The field contains a single media type specification indicating the type of content in the body of the message. For more information, see RFC 7231 Semantics and Content, section 3.1.1.5. Content-Type on the RFC Editor website.
In a request message, a Content-Type field determines how data specified in theMessageBody.Data
property is converted. For information on this conversion, see HTTP Data Type Conversion. If a request message contains a nonempty body, but does not contain a Content-Type field, then MATLABĀ® creates a Content-Type field based on the data type.
Creation
Description
obj = matlab.net.http.field.ContentTypeField(value)
creates a Content-Type header field with the Value property set tovalue
.
Properties
Header field name, specified as 'Content-Type'
.
Attributes:
GetAccess | public |
---|---|
SetAccess | public |
Dependent | true |
Media type, specified as a matlab.net.http.MediaType object or a string acceptable to the MediaType
constructor.Value
cannot contain a quality ('q'
) parameter.
Example: 'text/html;charset=utf-8'
Attributes:
GetAccess | public |
---|---|
SetAccess | public |
Methods
addFields | Add fields to HeaderField array |
---|---|
removeFields | Remove fields from header field array |
changeFields | Change existing values in HeaderField array |
replaceFields | Change values in or add fields to array of HeaderFields |
getFields | Return header fields matching name or class |
eq | Compare two HeaderField arrays |
convertLike | Convert header field value like another header field |
parse | Parse header field value and return as strings |
displaySubclasses | Display supported HeaderField subclasses |
convert | Parse ContentTypeField as a comma-separated list of values and converts each Value property to aMediaType object. Each value is a media-type expression as defined in RFC 7231 Media Type, section 3.1.1.1 on the RFC Editor website. |
---|
These methods specialize standard MATLAB operators and functions for objects in this class.
isequal | true if two header field arrays are the same size and corresponding elements are equal, as described by eq method. |
---|---|
string | Array of header fields as string, as it appears in a message. Insert newline characters between fields but not at the end of all fields. |
char | Array of header fields as character vector, as described bystring method. |
Examples
This example shows how to read the Content-Type field in a message.
import matlab.net.; import matlab.net.http.;
httpsUrl = 'https://requestserver.mathworks.com'; uri = URI(strcat(httpsUrl, '/assets/computerVision.jpg')); req = RequestMessage('GET'); response = req.send(uri); contentTypeField = response.getFields("Content-Type"); disp(contentTypeField)
ContentTypeField with properties:
Name: "Content-Type"
Value: "image/jpeg"
Version History
Introduced in R2016b