matlab.net.http.io.ContentProvider.complete - Complete HTTP header for ContentProvider - MATLAB (original) (raw)
Main Content
Class: matlab.net.http.io.ContentProvider
Namespace: matlab.net.http.io
Complete HTTP header for ContentProvider
Syntax
complete(provider,URI)
Description
complete([provider](#d126e827613),[URI](#d126e827634))
augments the header of the message with header fields required by this provider. TheRequestMessage.send
and RequestMessage.complete
methods call this method before validating the header or adding any default fields, and before calling other methods in this class except forexpectedContentLength
.
This is where subclasses can add any fields to Header that depend on the content, such as Content-Type. See the description of the Header
property for more information.
The RequestMessage
methods do not call this method if the message has already been completed (that is, if RequestMessage.Completed
istrue
). However, a subsequent change to the message after completion resets the RequestMessage.Completed
property, allowing those methods to invoke this method again. Therefore, providers should be prepared for more than one call to complete
before a call to start
. Once start
has been called, MATLABĀ® does not reinvoke complete
in this provider unlessreusable
returns true
to indicate that this provider can be reused for another message.
A ContentProvider
that extends another ContentProvider
should first call its superclass complete
method to add header fields to Header
that the superclass needs, and then, on return, modify those fields if desired.
The default behavior of this method does nothing, but throws an exception if this provider has been started and is not reusable. Providers that override this method should always invoke their superclass.
If this provider is not a multipart delegate, and you want to include a Content-Length field in the message (thereby avoiding chunked transfer coding), then you should return a nonempty value in expectedContentLength
or implement this method to insert a Content-Length field in the Header
.
This method is not invoked on messages with a Completed
property set to true
, which generally means that this method is invoked only once per message, even if this message is resent multiple times. Implementations of this method should, therefore, perform any initialization that needs to be done only once per message. Costly initialization that does not need to be done until the data is ready to be sent should be performed in the start
method.
Input Arguments
Content provider, specified as amatlab.net.http.io.ContentProvider
object.
Uniform resource identifier, specified as a matlab.net.URI
object.
Attributes
Examples
The following is a coding pattern for aContentProvider
that extends aSuperclassProvider
and adds theHeaderField
myField
.
function complete(obj, uri) complete@SuperclassProvider(obj, uri); field = obj.Header.getFields('My-Field'); if isempty(field) myField = HeaderField('My-Field', value); obj.Header = obj.Header.addFields(myField); end
Version History
Introduced in R2018a