complete
Class: matlab.net.http.RequestMessage
Namespace: matlab.net.http
Validate and complete HTTP request message without sending
Syntax
Description
[
adds and validates message header fields and converts data like the
completedrequest
,target
] = complete(request
,uri
)RequestMessage.send
method, but does not send the message.
complete
assumes a default HTTPOptions
object to
determine how to complete and validate the request.
Use the complete
method to examine the contents
of a request message for debugging purposes.
To fill in and validate the Header
and
RequestLine
properties, this method ignores the
Completed
property in request
. The
method always returns a modified completedrequest
. If
request
is not completed, then the method errors. You can
use this behavior to determine whether a manually completed request is valid.
If Completed
is not set, then this method always converts
Data
in request.Body
and stores the
result in completedrequest.Body.Payload
, overwriting any
previous contents of Payload
. This means that both
Data
and Payload
in
completedrequest.Body
contain values. This is different
from the behavior of the send
which does not save the
Payload
unless HTTPOptions.SavePayload
is set. If the message contains a large amount of data, then memory usage and
conversion time might be a factor.
However, if request.Body
contains a
ContentProvider
, then complete
does not call the
provider to create data. completedrequest.Body
contains the
same ContentProvider
.
[
provides
additional options for validating and completing the request message.completedrequest
,target
] = complete(request
,uri
,options
)
If you intend to send completedrequest
to avoid the cost of a
repeat validation, send it to target
instead of
uri
, using the same options
.
Time-dependent header fields such as Date
which are added by the
send
method, are not updated when sent again using
completedrequest
.
Input Arguments
Output Arguments
Examples
Limitations
A completed request does not add any authorization header fields that might be needed for authentication to a server or proxy, even if the
Authenticate
property is set inoptions
. It might not be possible to determine what the server requires without sending the message. To see what was sent in an authentication exchange, examine thecompletedrequest
orhistory
arguments returned by thesend
method.
Tips
To send the same request message repeatedly, send
completedrequest
. Otherwise, if you sendrequest
, then MATLAB repeatedly validates the message. Also be sure to specifytarget
as the URI and the sameoptions
input argument. Time-dependent header fields such as Date, which thesend
method adds, are not updated when sendingcompletedrequest
.To complete a message without converting the data, set the
Completed
property totrue
before calling thecomplete
method. IfCompleted
is true andrequest.Body
is aMessageBody
object, then thecomplete
method assumes that the current value ofrequest.Body.Payload
is the desired one, even if it is empty.This behavior differs from the
send
method. Ifrequest.Body.Payload
is empty, thensend
converts and sends nonemptyBody.Data
values, even ifCompleted
is true.
Version History
Introduced in R2016b