WebHeaderAdd Function

Action

Adds a custom HTTP header to the next WebUrl* or WebForm* function. This also enables replacing standard headers, like the default POST encoding type "Content-Type: application/x-www-form-urlencoded", with a custom encoding type. You can add up to 128 headers per request by calling this function repeatedly.

Include file

WebAPI.bdh

Syntax

WebHeaderAdd( in sName  : string,
              in sValue : string ): boolean;

Return value

  • true if the header information was accepted

  • false otherwise

Parameter Description
sName Name of the HTTP header
sValue Value string of this header

Example

dcltrans
  transaction TWebOwnAuthHeader
  var
    sUserPass    : string(200);
    nUserPassLen : number;
  begin
    // Build your own authentication header
    WebBase64Encode(sUserPass, 200, nUserPassLen,
                    "smith:paranoia{}[]~^",
    Strlen("smith:paranoia{}[]~^"));
    sUserPass := "Basic " + sUserPass;
    WebHeaderAdd("Authorization", sUserPass);
    WebUrl("http://standardhost/", 0.0);
  end TWebOwnAuthHeader;

Sample scripts

WebEncoding01.bdf, WebHttpHeaders01.bdf