SetHeader Method  
 

Sets the value of a custom HTTP header used with subsequent requests.

Syntax

object.SetHeader( HeaderName, HeaderValue )

Parameters

HeaderName
A String value which specifies the name of the HTTP request header. The header names are not case-sensitive.
HeaderValue
A String value which specifies the header value. Header values cannot contain carriage-return or linefeed characters. If the value contains Unicode characters, they will be UTF-8 encoded. If this parameter is an empty string, the header field is deleted from the request headers.

Return Value

A value of True is returned if the method completed successfully. If the method fails, it will return False and the LastError property will contain the error code.

Remarks

The SetHeader method assigns a custom HTTP request header that will be included with subsequent requests made using the current client session. If the specified header already exists in the custom header list, its value will be replaced. If the header value is an empty string, the header will be removed.

This method is intended for advanced applications that require lower-level access to provider-specific functionality. Most applications should not need to use custom request headers. Some headers are managed internally by the control and cannot be overridden using this method. This includes headers required for authentication, content formatting, message length, host identification, and other protocol-specific functionality required by the current provider.

Examples of headers that are managed internally by the control include:

  • Authorization
  • Content-Length
  • Content-Type
  • Host
  • User-Agent

Custom headers remain associated with the current client session until they are removed using the ClearHeaders method or the control is reset or uninitialized.

See Also

ApiKey Property, BaseUrl Property, UserAgent Property, ClearHeaders Method, GetHeader Method, SendMessage Method