Method HttpClient():setAcceptCharset() Foundation

Defines the accepted charset for responses from the server.

Syntax
 
:setAcceptCharset( <cCharset> | <aCharsets> ) --> self
Parameters
<cCharset>
A character string with a charset identifier.
<aCharsets>
An array of charset identifiers specified as character strings. The elements in the array may optionally be weighted by using a so-called quality value. The quality value is a value between 0 and 1 denoting the charset's priority. A weight value of 1 (the default) is equivalent to the highest priority.
Example: 
:setAcceptCharset( "utf-8" ) // specific charset 
:setAcceptCharset( {"utf-8", "iso-8859-1;q=0.5"} ) // weighted charset list 
Return

:setAcceptCharset() returns the object executing the method.

Description

The method :setAcceptCharset() specifies to the server which character set(s) the client is able to unterstand when processing data sent by the server.

The accepted charset is a discretionary element in the request header. Although servers are expected to respect the proposal(s) made by the client, there is no guarantee the response will be in the desired format. Consequently, the "Content-Type" HTTP header in the :httpResponse object should be checked prior to processing the response data. See the method :getHeaders() for further information.

The charset(s) specified in the parameters to :setAcceptCharset()are stored in the "Accept-Charset" header element of the HTTP request object assigned to the :httpRequestmember variable. This HTTP request object is used as the default for requests sent using the methods :send() and :sendAsync().

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.