WebModifyHttpHeader Function

Action

Sets, modifies or removes one or more user-defined headers for HTTP/HTTPS. Note that this function is only applicable to certain HTTP headers. It cannot be used to modify headers such as Accept, User-Agent and Accept-Encoding.

  • For Accept, use the function WebSetAcceptTypes.
  • For User-Agent, use the function WebSetUserAgent.
  • For Accept-Encoding, use the function WebSetOption(WEB_OPT_ENABLE_CONTENT_ENCODING, 0); It disables the default accept-encoding.

Include file

WebAPI.bdh

Syntax

WebModifyHttpHeader( in sHeader : string,
                     in sValue  : string allownull,
                     in nOption : number optional ): boolean;

Return value

  • true if successful

  • false otherwise

Parameter Description
sHeader User defined header.
sValue Value of the specified header.
nOption

Can be one of the following values:

WEB_MODIFY_OPT_Add
Adds the specified header to the actual set of headers.
WEB_MODIFY_OPT_ReplaceFirst
Replaces the value of the first header with identical name. All following headers with the same name (if present) are not changed. To remove all those headers use the WEB_MODIFY_OPT_RemoveAdd option. If no header with the specified name can be found, a new header is added.
WEB_MODIFY_OPT_Remove
Removes all headers with the specified name. The value of sValue is ignored.
WEB_MODIFY_OPT_RemoveAdd (default)
Removes all headers with the specified name and adds the specified sHeader – sValue pair.

Example

dcltrans
  transaction TWeb
  begin
    WebModifyHttpHeader("Accept-Language", "en-us");
    WebPageUrl("http://server/");
    WebModifyHttpHeader("Accept-Language", "de", WEB_MODIFY_OPT_Add);
    WebPageUrl("http://server/");
  end TWeb;