Main Content



Process next buffer of data for MultipartConsumer


[length,stop] = putData(consumer,data)


[length,stop] = putData(consumer,data) accumulates buffers of data until an entire part of a multipart message has been assembled. It then uses the Content-Type field in the part's header to find an appropriate ContentConsumer delegate that can handle that type, sets the delegate's Header property to the header of the part, and then calls initialize and start in that delegate. It follows that with one or more putData calls, passing in the part's payload, and then calls putData(uint8.empty) to indicate the end of the payload.

After the final call to the delegate's putData, this method creates a ResponseMessage containing the header of the part and a Body copied from Response.Body in the delegate. (That Body might or might not contain data, depending on what the delegate does.) It adds that new ResponseMessage to the array of ResponseMessage objects in this consumer's Response.Body.Data property, which, when the end of the message has been reached, contains one ResponseMessage for every part.

This method is an overridden method of putData. If you override this method and return stop=true before the end of the message (if data is not empty) in order to terminate receipt of the message before the normal end of message, you should avoid calling this superclass method on the subsequent putData(uint8.empty) call that MATLAB® normally makes after you set stop. Failure to do so results in an invalid message exception from MultipartConsumer due to a premature end of message.

Input Arguments

expand all

Content consumer, specified as a object.

Buffer of raw data in a object, specified as a nonempty uint8 vector, uint8.empty, or []. For more information about these values, see the data input argument for the ContentConsumer.putData method.

If data is [] to indicate that the message has ended and there was a delegate, copies the Response property from the delegate to this object's Response.

Output Arguments

expand all

Length of data processed, returned as double or empty double. For more information, see the size argument in ContentConsumer.putData.

Indicate whether to receive further data from this message, returned as true or false. For more information, see the stop argument in ContentConsumer.putData.


Introduced in R2018a