Main Content

getData

Class:matlab.net.http.io.ContentProvider
Package: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 duringRequestMessage.send, after callingstart, and sends each buffer ofdatato the server immediately. If the message is chunked (for example,expectedContentLengthreturned empty and there is no Content-Length field in the message), then the size of the chunk is the length ofdata.

Input Arguments

expand all

Content provider, specified as amatlab.net.http.io.ContentProviderobject.

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 ofpreferredBufferSize, 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 ignorelength. MATLAB does not guarantee that any specific value oflengthis specified, but it always is a finite number greater than zero. Returning a large buffer ofdatamight cause MATLAB to block for a considerable time while sending the data, during which you cannot interrupt the operation usingCtrl+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 auint8vector or empty. Ifdata是空的,stopis not set, then MATLAB calls this method repeatedly to get more data (after a small delay). To end the message, returnstop=true. However, you can also throw an exception to abort the message, which is returned to the caller ofRequestMessage.send.

If the Content-Length header field was included in the message header or returned byexpectedContentLength(that is, the message is not being sent using chunked transfer coding), then the total number of bytes returned indataover multiple calls, ending withstop=true, must be equal to that number. Ifstop=trueis returned prematurely, or the total amount ofdatareturned 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. Iffalse, then MATLAB calls thisgetDataagain to get more data when it is ready to send the next buffer. Iftrue, then this indicates that the provider has no more data to send, beyond what is returned indata, and tells MATLAB to end the message. This is the normal way to end theRequestMessageand prepare MATLAB to receive aResponseMessage.

Attributes

Access public

版本历史

Introduced in R2018a