Classes

Method HttpClient():setUserAgent() Foundation

Sets the user agent.

Syntax
 
METHOD :setUserAgent( <cUserAgent> ) --> self
Parameters
<cUserAgent>
A character string identifying this HTTP client object to the server. The id string contains information about one or more components of the user agent. Each component is listed with its name, version number and an optional comment using a sub-string of the form "name/version (comment)". If several components are described in the id string, the corresponding sub-strings must be separated from each other using a white space character.
Return

:setUserAgent() returns the object executing the method.

Description

The method :setUserAgent() defines how the HTTP client object identifies itself as a user agent when making requests to the server. Some servers use the user agent string for making assumptions about the application requesting a resource, and may choose to serve different content based on this decision. In such a scenario, applications may use :setUserAgent() to be able to mimmick a certain application or browser behavior.

By default, HTTP client objects identify themselves using an id string containing the token "Xbase++", the major and minor product version and the operating system version as returned by the Os() function. This default value can be overriden with the :setUserAgent() method. The following is an example of a default user agent string:

"Xbase++/2.0 (Windows 10 1709 Build 16299)" 

The user agent specified to :setUserAgent()is stored in the "User-Agent" 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().

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.