ContentProvider to send multipart/mixed HTTP messages
This provider helps with the creation of multipart HTTP messages.
The default Content-Type is
"multipart/mixed", and the payload of the
message contains an arbitrary number of parts, each part containing its own header describing
that part. For more information on multipart messages, see RFC 2046, section
Use this provider directly only if you know that your server accepts multipart/mixed
messages. Usually, servers that accept multipart messages instead require
"multipart/form-data", which is implemented by the subclass
MultipartFormProvider. You can implement other multipart types using
matlab.net.http.io.MultipartProvider class is a
Each of the parts of the multipart message can be specified as data in any of the
formats permitted for
RequestMessage.Body, or as a
ContentProvider that creates the data. The
objects that are used to supply data for the parts are called delegates, while this
MultipartProvider is the top level provider. In general, any
ContentProvider is suitable as a delegate. The
MultipartProvider invokes each delegate in turn as the message is being
sent, calling its methods, such as
that the delegate in general need not be aware that it is providing content for a part,
rather than for a whole message.
This provider always transmits the
RequestMessage as chunked, so it does
not include a Content-Length header field in the message or in the headers of any of the
MultipartProvider calls each delegate's
expectedContentLength method before sending the part, it only uses the
return value (if nonempty) to enforce the length, not to create a Content-Length field. If
the delegate does want a Content-Length field to appear in the part, it must insert such a
field explicitly in its
Header property. None of the
ContentProvider subclasses provided by MATLAB® do this processing.
provider = MultipartProvider(
MultipartProvider that sends the specified parts, in the
specified order, in an HTTP request. By default this provider sets the Content-Type of the
"multipart/mixed", but subclasses can alter the subtype by
Subtype property. The constructor sets elements of the
Parts property cell array to each
Parts— Message body parts
Parts of the message body, specified as a cell array of one or more of these values:
This treats each element of the array as a part. Not a cell array.
This method must have the signature of
Any other type
If the type does not match any of these types and is not a function
handle, then it is treated as if it was present in the
Header— Header fields of message or part
Header fields of the message or part, specified as a vector of one or more
This property is only used by subclass authors. MATLAB sets this property before calling the provider's
method. For non-multipart messages, MATLAB initializes this property to the contents of
Request.Header, minus any
empty-valued fields. The
ContentProvider uses this property to add header
fields that describe the data to be sent, or to add parameters to header fields already
in the message. In a delegate for a
MultipartProvider, MATLAB initializes this property to header fields that the delegating provider
intends to insert for the part. Delegates can modify or change these fields.
Upon return from the provider's
complete method, if this not a
multipart message, then MATLAB reads this property and merges its contents into the header of
Request. Fields in this
Names that do not already appear in
Request.Header are added to the end of
Request.Header. If a field in this
Name that is the same as one in
Request.Header, and both have nonempty
If the one in
Request.Header is a
GenericField, then ignore the one in
If the one in
Request.Header is not a
GenericField, then replace it with the one in
If one or both of these has an empty
Value, then the field is
Request.Header and it is not added as part of normal
If this is a delegate of a
MultipartProvider, then the entire contents
Header is used as the header of the part. Multipart
delegates must not assume that
Request.Header contains any fields
pertaining to their own
Header. A provider can determine whether it
is a multipart delegate by checking whether
MyDelegator is a
MultipartProvider, though this test is unlikely to be needed.
MATLAB reads this property only on return from calling the provider's
complete method. Changes to this array are ignored once MATLAB calls
Class authors should be aware that their subclasses might have added fields to this
Header (in their
complete method) before
complete in their superclass. It is best to preserve such
fields and not to add fields with the same names. However, adding a parameter to a field
is permissible. For example, a superclass can add a charset parameter to an existing
Content-Type field that does not already have one.
ForceChunked— Indicate whether to force chunked transfer coding
Indicate whether to force chunked transfer coding, specified as boolean. This property is of interest only to subclass authors, and is applicable only to providers that are not multipart delegates. Subclasses set
ForceChunked to control whether contents should be sent using chunked transfer coding. If
false (default), MATLAB decides whether to send the contents chunked, based on whether it knows the content length at the time the message is ready to be sent:
If MATLAB knows the content length (which is the case if the message contains a Content-Length field, or if this provider's
expectedContentLength method returned a number), then MATLAB decides whether to send it chunked or not.
If MATLAB does not know the content length (no Content-Length field in the header and
expectedContentLength returned empty), then MATLAB always sends the message chunked.
true, then MATLAB sends the message chunked regardless of whether it knows the content length, unless the known length is smaller than the chunk size. If this property is
true, then the message must not contain a Content-Length field, because HTTP does not allow a chunked message to have a Content-Length field. However, you can still return a nonzero value in the
expectedContentLength method if you want MATLAB to verify that you are returning the expected length of data.
When MATLAB chooses to send the message chunked, the size of each chunk is equal to the length of data returned by
Request— Request message to send
Request message to send, specified as a
This property is used only by subclass authors. The
methods set this property to the
RequestMessage in whose
Body this provider has been placed, before calling any other
methods in this provider, and before adding any additional header fields or validating
the message. The provider can examine this message to see what was contained in the
Delegates see the same value for this property as the delegator.
ContentProviders should be aware that, if they are delegates, they
are not necessarily providing the entire body of the request message, so they should not
assume that header fields in this Request are pertinent to the data they are providing.
Usually, delegates should ignore header fields in this request relevant to the data,
such as Content-Type.
If the provider wishes to add any header fields to this message, or to modify existing
ones, it should do so in its
method by adding those fields to the
Header property. The caller of
RequestMessage or a delegating provider)
determines what to do with those fields.
RequestMessage.complete always copy these fields to the
Header of the
RequestMessage. A delegating
provider can copy the fields to its own
Header property or insert
them into the message (as in the case of
MultipartProvider). For more
information, see the Header property.
This property is read-only.
Subtype— Provider subtype
"mixed"(default) | string
Provider subtype, specified as a string. The default value
"mixed" adds a Content-Type header set to
"multipart/mixed" to the message, plus appropriate parameters.
Subclasses can alter this value in the constructor or the
method. This value appears in the Content-Type after
ContentProviderto which this provider is delegating
ContentProvider to which this provider is delegating, specified as a
matlab.net.http.io.ContentProvider object. This property is set in the calling provider (the delegator) by the
delegateTo method to indicate the current delegated provider. If there is no current delegation, then the value is empty.
complete methods set this property to empty.
ContentProviderthat delegated to this provider
ContentProvider that delegated to this provider, specified as a
ContentProvider delegates responsibility for sending all or a portion of the message data to another provider, then this property identifies the delegating provider to the delegate. For example, a
MultipartProvider delegates parts of the message to other providers, so it inserts a handle to itself in each delegate. Otherwise,
MyDelegator is empty. The
delegateTo method sets this property in the delegate.
|Next buffer of data to send in multipart HTTP request message|
These methods specialize standard MATLAB operators and functions and inherited methods for objects in this class.
Provider information as string
Display provider information
|Complete HTTP header for MultipartProvider|
|Preferred buffer size for ContentProvider|
|Content length of ContentProvider|
|Start data transfer from MultipartProvider|
|Indicate whether ImageProvider is restartable|
|Indicate whether ImageProvider is reusable|
|Delegate to another provider|