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


HTTP request or response message


The Message class is an abstract class used as a base class to create HTTP messages.


expand all

First line of message, specified as a object, if any.

Message header, specified as a object or a vector of HeaderField objects. When you set the Header property, MATLAB® checks the fields of the header to ensure that they are appropriate for the message type. The RequestMessage send and complete methods fill in any required header fields for a properly formed request.

Message body, specified as a object,, or data acceptable to the MessageBody constructor. By default, Body is empty (set to []). A request message containing a Body property normally uses a method such as 'PUT' or 'POST', not the default value 'GET', but this convention is not enforced.

In a completed or received message, if the message has a ContentTypeField header field, then the MessageBody.ContentType property is set to that value. Otherwise, ContentType is unchanged or empty.

Whether message is complete, specified as true or false. A true value means that the message is complete.

RequestMessage methods that validate messages (send and complete) set the Completed property to true when:

  • The message is valid.

  • The processing is complete. For example, required header fields are added and the data is converted.

If the property is true, then these methods do not modify the message, and the send method sends the message without checking it for validity. Any later changes to this message change the value of Completed back to false.

Methods that return messages set Completed to true when:

  • The Body or Body.Data properties are empty.

  • The Body.Payload property contains the raw data.

If a request message contains data (Body.Data is not empty), then the property is true only if Body.Payload contains the raw data.

In a response message, the payload is set only if you set the HTTPOptions.SavePayload property to true.



Data Types: logical


addFieldsAdd fields to message header
changeFieldsChange existing fields in message header
charReturn message as character vector
getFieldsReturn message header fields matching name or class
removeFieldsRemove fields from message header
showDisplay or return formatted version of message
stringReturn message as string


  • To send arbitrary headers and data in a request message, set the Completed property to true to prevent the send method from modifying the message. You still can use the complete method to validate the message, but the send method does not validate the message.

Introduced in R2016b

Was this topic helpful?