matlab.net.http.io.StringConsumer Class
Namespace: matlab.net.http.io
Superclasses: matlab.net.http.io.ContentConsumer
String consumer for HTTP payloads
Description
A StringConsumer stores character data in a response message, decoded
according to the charset based on the Content-Type, in the response body. You can specify this
consumer directly when sending a RequestMessage to specify a string conversion
for the data with certain parameters.
For an example subclassing this consumer, see the PricesStreamer class
in Display Streamed Data in Figure Window.
The matlab.net.http.io.StringConsumer class is a handle class.
Creation
Description
consumer = StringConsumer constructs a consumer that converts input
to a scalar string using the character set specified in the Content-Type of the
message.
consumer = StringConsumer(
constructs a consumer with options specified by one or more
Name,Value)Name,Value pair arguments. Name is the property
name Charset or TextType and
Value is the corresponding value. You can specify the name-value pair
arguments in any order as Name1,Value1,Name2,Value2.
If you do not specify a Charset property, then this consumer
tries to derive the charset from the ContentType property, which
MATLAB® sets based on the Content-Type field in the Response.
StringConsumer knows the charset if ContentType has
an explicit charset parameter, or if it is one of the types for which MATLAB knows the default charset:
"text/*"- US-ASCII or UTF-8 depending on the subtype."application/*"- UTF-8 for subtypes: json, xml, javascript, css, x-www-form-urlencoded; unknown otherwise.
If this consumer cannot determine the charset from the
ContentType in the message, then this consumer rejects the message
and it is not converted. In that case, the ResponseMessage.Body
contains only a uint8 payload. If you want to convert a message with an unknown charset,
then set Charset in this consumer before applying it to a message
(or, if you are a subclass author, before calling the initialize method).
A good one to use is UTF-8 because that is a superset of US-ASCII and some other
charsets.
Properties
Methods
More About
Version History
Introduced in R2018a
See Also
ResponseMessage | putData | initialize | ContentConsumer | StringProvider | ContentTypeField
