Main Content

delegateTo

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

Delegate to another provider

Description

[getDataFnc,length] = delegateTo(provider,delegate,URI)sets up adelegateContentProviderto provide all or part of the subsequent data in aRequestMessage. This method initializes properties in the delegate using properties of this object and supplied parameters, as if a new message was about to be transmitted using that delegate, and invokes thecomplete,expectedContentLength, andstartmethods in thedelegate. It returns a handle to a function,getDataFnc, that you invoke to obtain data from the delegate:

[data, stop] = getDataFcn(length)

where the arguments are as described forgetData. You can use any value oflength, but normally you make this call in yourgetDatamethod, passing the same value that was passed to your method.

To delegate to a provider that provides the entire contents of a message, calldelegateToin yourstartmethod. If you use the delegate to obtain part of the message content, then calldelegateToat the appropriate time in yourputDatamethod.

To obtain data from the delegate, always use the returnedgetDataFnc. Do not call the delegate'sgetDatadirectly because the delegate might provide its data through some other means.

[getDataFnc,length] = delegateTo(___,force)indicates if theexpectedContentLengthmethod should return the length of the data.

Input Arguments

expand all

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

Provider for subsequent data, specified as amatlab.net.http.io.ContentProviderobject.

Destination of the request being processed, specified as amatlab.net.URIobject. The value is the URI provided to the caller'scompletemethod.

Indicate whether theexpectedContentLengthmethod should return the length of data, specified astrueorfalse. ThedelegateTomethod passes this value toexpectedContentLength.

Output Arguments

expand all

Function to get data from a delegate, returned as a function handle.

Value returned by theexpectedContentLengthmethod, returned as bytes. For more information, see thelengthoutput argument forContentProvider.expectedContentLength.

Attributes

Access protected

版本历史

Introduced in R2018a