Main Content

start

Class: matlab.net.http.io.ContentConsumer
Namespace: matlab.net.http.io

Start HTTP data transfer to ContentConsumer

Syntax

bufsize = start(consumer)

Description

bufsize = start(consumer) signals the start of an HTTP transfer.

MATLAB® calls start when it is ready to send data to the consumer, after it calls the initialize method that returned true. All consumers must implement this abstract method.

The start method differs from initialize in that it is invoked only if the message contains a payload. MATLAB calls initialize as soon as it receives the message header. Hence, it might be better to perform initializations in start rather than initialize, so that it is not done if the message is empty.

Input Arguments

expand all

Content consumer, specified as a matlab.net.http.io.ContentConsumer object.

Output Arguments

expand all

Maximum buffer size that MATLAB passes to each call to the putData method, returned as double. The method returns the maximum size of the buffer, although MATLAB might pass in a smaller size.

start returns [] if the consumer can always process all of the data immediately, regardless of the size, to let MATLAB choose the best size. Specifying a smaller size is useful for slowly arriving data, as it allows you to receive data in a more timely manner rather than waiting for a large buffer to be filled.

If the server sends chunked-encoded messages, and if you want to be sure that each call to putData contains a whole chunk, then return [] or a value larger than the maximum chunk size. MATLAB never provides more than a single chunk at a time in one call to putData, but it might provide a part of a chunk if the chunk is larger than bufsize or MATLAB's internal buffer size.

Attributes

Abstractprotected

Version History

Introduced in R2018a