Prepare consumer for new HTTP payload
OK = initialize(consumer)
initialize after receipt of the header of a
ResponseMessage that might contain a payload, to prepare the consumer
for that payload. It is not invoked for messages not expected to contain a payload, such
as those with an explicit Content-Length of 0, or in error cases where a complete header
was not received.
method in a delegate consumer also calls
If you subclass a
ContentConsumer, then you should at least check the
ContentType property to verify that the response is of the type you are
prepared to handle. You can override this method to, for example:
Initialize your own properties
Determine if you want to process the payload
Process a payload that has a
It is up to you whether to perform any subsequent initializations in this method or
delay them until the
initialize is called, MATLAB might not call the consumer's
method if the message has no payload.
The default implementation returns
true if the
false otherwise. Subclasses that override this method should
invoke this superclass method first and check the return value, unless they want to
process messages with a status other than
OK. Subclasses that invoke
putData in this class must call this method.
Consumer subclasses should be prepared to be reused for subsequent messages.
initialize before each message and then
start for each message that has a nonempty payload. Once
start, it does not call
until the message has ended, an exception was thrown, or an interrupt occurred during
message processing. All these cases are indicated by a call to
consumer — Content consumer
Content consumer, specified as a
OK — Indicate whether consumer accepts or rejects message payload
true (default) |
Indicate whether the consumer accepts or rejects the payload of the
message, returned as
If the status code of the
StatusCode.OK, then the default is
true, then the consumer accepted the message and processes the payload, if any. MATLAB then calls the consumer's
startmethod when the first byte of the payload arrives, followed by one or more calls to
putData, passing a buffer of data on each call.
false, then the consumer does not want to process the message, in which case MATLAB processes the payload as if no consumer had been specified (which might mean default conversion of payload to data).
If you override the
initialize method and reject the
message and you want to abort receipt of the message instead of processing
it in a default manner, then throw an error from this method instead of
Introduced in R2018a