Main Content

getData

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

Next buffer of data to send in HTTP request message from ContentProvider

Syntax

[data,stop] = getData(provider,length)

Description

[data,stop] = getData(provider,length) returns a buffer of data to send in an HTTP request message.

MATLAB® calls this method multiple times during RequestMessage.send, after calling start, and sends each buffer of data to the server immediately. If the message is chunked (for example, expectedContentLength returned empty and there is no Content-Length field in the message), then the size of the chunk is the length of data.

Input Arguments

expand all

Content provider, specified as a matlab.net.http.io.ContentProvider object.

Length of data that the provider should return for optimum interactive behavior, specified as double.

The value is a suggested length based on the value of preferredBufferSize, if specified, and the internal buffer sizes. The provider can, however, return more or fewer bytes, and if your provider wants to send chunks of specific sizes, it can ignore length. MATLAB does not guarantee that any specific value of length is specified, but it always is a finite number greater than zero. Returning a large buffer of data might cause MATLAB to block for a considerable time while sending the data, during which you cannot interrupt the operation using Ctrl+C. This might not be an issue for non-interactive applications, where larger buffers are efficient.

Output Arguments

expand all

Next buffer of data, returned as a uint8 vector or empty. If data is empty and stop is not set, then MATLAB calls this method repeatedly to get more data (after a small delay). To end the message, return stop=true. However, you can also throw an exception to abort the message, which is returned to the caller of RequestMessage.send.

If the Content-Length header field was included in the message header or returned by expectedContentLength (that is, the message is not being sent using chunked transfer coding), then the total number of bytes returned in data over multiple calls, ending with stop=true, must be equal to that number. If stop=true is returned prematurely, or the total amount of data returned is greater than that number, then MATLAB throws an exception and closes the connection.

Indicate whether to end transmission, returned as a logical that the provider must set. If false, then MATLAB calls this getData again to get more data when it is ready to send the next buffer. If true, then this indicates that the provider has no more data to send, beyond what is returned in data, and tells MATLAB to end the message. This is the normal way to end the RequestMessage and prepare MATLAB to receive a ResponseMessage.

Attributes

Accesspublic

Version History

Introduced in R2018a