CHttpClient::GetEncodingType Method  
 
INT GetEncodingType();

The GetEncodingType method determines which content-encoding option is enabled.

Parameters

None.

Return Value

If the method succeeds, the return value is one of the following values:

Value Description
HTTP_ENCODING_NONE No encoding will be applied to the content of a request and no default content type will be specified. This encoding type should be used with REST APIs and other services which expect XML or JSON request payloads.
HTTP_ENCODING_URL Non-printable and extended ASCII characters will be encoded so they can be safely used with URLs and form data. Encoded characters will be represented by a percent symbol prefix, followed by a two digit hexadecimal value which represents the ASCII character code. This encoding is typically used with web services which process HTML form data.
HTTP_ENCODING_XML This encoding is identical to URL encoding, except spaces are not encoded. It is used with legacy web services which expect form data in an XML format and cannot process encoded whitespace. This encoding should not be specified for services which use REST APIs.

If the method fails, the return value is HTTP_ERROR. To get extended error information, call GetLastError.

Remarks

The default encoding type is HTTP_ENCODING_URL which is used for submitting data to services which expect HTML form data using the HttpPostData or HttpSubmitForm functions.

When submitting a JSON or XML request to a service using a REST API, your application should use HTTP_ENCODING_NONE and set the appropriate content type for the request payload. The HTTP_ENCODING_XML encoding type should only be used if the server expects URL encoded form data. The PostJson and PostXml methods will automatically set the correct encoding and content type for those requests.

Requirements

Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cstools12.h
Import Library: cshtpv12.lib
Unicode: Implemented as Unicode and ANSI versions

See Also