If the method succeeds, the return value is the number of
characters copied into the string buffer. If the method fails, the return value is
HTTP_ERROR. To get extended error information, call
HttpGetLastError.
The SetDefaultUserAgent method changes the
default user agent string which is included with each request made by
the client. This default value is global and changing it will change
the default user agent for all client sessions in all threads created
by the process.
The user agent string should use a format with the product name and
version number separated by a slash. There can be multiple products
listed in the user agent string separated by spaces, with additional
optional information enclosed in parenthesis. For example, a valid
user agent string for an application named "MyProgram" could
look like this:
MyProgram/1.0 (Win32)
Some web services check the value of the user agent string to
determine if a compatible client is being used to issue the request.
The default value used by SocketTools is designed to emulate a common
browser, but some services may require you change the user agent to
use a specific value or include certain product names and versions.
To change the user agent string for a specific client session, use
the SetHeader method to set a value for the User-Agent
header. To get the current value of the default user agent string, use
the GetDefaultUserAgent method.
To prevent any user agent string from being included with a
request, include the HTTP_OPTION_NOUSERAGENT option when connecting to
the server or use SetOption to enable that option
after a connection has been established.
Using the HTTP_OPTION_NOUSERAGENT option to prevent sending a
User-Agent header does not make requests anonymous. Servers may still
identify clients based on IP address information, authentication
credentials, request patterns or other HTTP headers included with
the request.