Main Content

convertLike

Class:matlab.net.http.HeaderField
Package:matlab.net.http

Convert header field value like another header field

Description

example

value= convertLike(fields,other)converts theValueproperty of each element offieldsto a MATLAB®type, using conversion rules of the fieldother.

For each header field infields, MATLAB checks thematlab.net.http.fieldpackage for a class that supports a name with the same value as thefields.Nameproperty. If the package contains a class for this field, thenconvertinvokes theconvertmethod of that class. To see the classes in thefieldpackage, call thematlab.net.http.HeaderField.displaySubclassesmethod.

If the conversion fails or if no class supports one of thefields.Nameproperties, thenconvertLikethrows an exception.

This method does not support heterogeneous arrays. All members offieldsmust be the same class.

Input Arguments

expand all

Header fields, specified as a vector ofmatlab.net.http.HeaderField对象. All members offieldsmust be the same class.

Field to use for conversion rules, specified as string, character vector,HeaderFieldobject, ormeta.classidentifying aHeaderFieldsubclass in thematlab.net.http.fieldpackage.

Output Arguments

expand all

Header field values, returned as a vector of MATLAB types. The types returned depend on the value of the specific classconvertmethod.

Examples

expand all

Theresponsevariable is a message that has aCreated-Dateheader field. Its value is formatted like anHTTPDateFieldobject, which returns adatetimeobject.

myField = response.getFields('Created-Date'); date = myField.convertLike(?matlab.net.http.field.HTTPDateField);
Introduced in R2016b