Method HttpClient():setAcceptType() Foundation

Defines the accepted content type for responses from the server.

Syntax
 
:setAcceptType( <cMIMEType> | <aMIMETypes> ) --> self
Parameters
<cMIMEType>
A character string specifying the content type. The string must contain one of the standardized MIME (Multipurpose Internet Mail Extension) types. A MIME type generally has the form "type/subtype". Examples are "text/html", "image/jpeg" or "application/octet-stream". A full list of the offical MIME types currently registered is available here: https://www.iana.org/assignments/media-types/media-types.xhtml.
<aMIMETypes>
An array of content types as described for the <cMIMEType> parameter. The elements in the array can optionally be weighted by using a so-called quality value. The quality value is a value between 0 and 1 denoting the language's priority. A weight value of 1 (the default) is equivalent to the highest priority.
Example: :setAcceptType( {"text/html; q=1.0", "text/*; q=0.8"} )
Return

:setAcceptType() returns the object executing the method.

Description

The method :setAcceptType() specifies to the server which content types are supported by the client for the data sent by the server.

The content type that is sent by the server when processing a request can be obtained via the method :getHeaders() of the reponse object stored in the :httpResponsemember variable.

The accepted content type specified to :setAcceptType()is stored in the "Accept" header element of the request message object assigned to the :httpRequestmember variable. This HTTP request object is used as the default for requests sent using the methods :send() and :sendAsync().

The accepted content type is a discretionary element in the request header. The "Content-Type" HTTP header in the server's response should be checked prior to processing the response data. See the method :getHeaders() for further information.

Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.