matlab.net.http.Message.replaceFields - Change values in or add fields to message header - MATLAB (original) (raw)
Class: matlab.net.http.Message
Namespace: matlab.net.http
Change values in or add fields to message header
Syntax
Description
msg = replaceFields([msg](#mw%5Fd5777fc0-3110-41f1-9fae-399c1b02a28d%5Fsep%5Fshared-msg),[FieldName1,FieldValue1,...,FieldNameN,FieldValueN](#mw%5F44a56f17-26fb-459d-899f-1aac3e665141))
replaces fields with the specified names to the indicated values specified inFieldName1,FieldValue1,...,FieldNameN,FieldValueN
and returns the updated message.
This method is the same as the changeFields method, but if a field does not exist which matches the name or class, then the method adds a new one to the end of the header instead of throwing an error.
msg = replaceFields([msg](#mw%5Fd5777fc0-3110-41f1-9fae-399c1b02a28d%5Fsep%5Fshared-msg),[newFields](#mw%5Fd5777fc0-3110-41f1-9fae-399c1b02a28d%5Fsep%5Fref%5Fq3fxxdid06-ids))
replaces the existing fields in each message to the names, values, and types specified in newFields
and returns the updated message.
Input Arguments
Fields defined by name-value pairs. FieldName
is specified as a string or character vector, and FieldValue
is specified as any type valid for FieldName
.
To use the default value for the field, set FieldValue
to ''
.
If the last value is missing, it is the same as specifying empty ([]
).
Names to match, specified as one of the following.
- String vector, character vector, cell array of character vectors, or comma-separated list of strings or character vectors containing the names of the fields to replace. Names are not case-sensitive.
- Vector or comma-separated list of one or more
HeaderField
objects whoseName
properties are used to determine which fields to replace. Names are not case-sensitive. Header field values are ignored. - Vector or comma-separated list of
matlab.metadata.Class
objects that are subclasses ofHeaderField
.
ThereplaceFields
method searches for names that match names supported by the specified classes, regardless of the class. If a subclass does not have a specific set of supported names, all header fields of that subclass are matched regardless of their names. Call theHeaderField.displaySubclasses
method to see supported names.
Version History
Introduced in R2016b