4.12.1.6 Header Modification Functions

There are two ways to modify message headers in a MFL script. First is to use header actions, described in Action Statements, and the second way is to use message modification functions. Compared with the actions, the functions offer a series of advantages. For example, using functions you can construct the name of the header to operate upon (e.g. by concatenating several arguments), something which is impossible when using actions. Moreover, apart from three basic operations (add, modify and remove), as supported by header actions, header functions allow to insert a new header into a particular place.

Built-in Function: void header_add (string name,   string value [, number idx])

Adds a header ‘name: value’ to the message. If idx is given, it specifies a 0-based index in the header list where to insert this header.

If idx is not supplied, the header is appended to the end of the header list.

In contrast to the add action, this function allows to construct the header name using arbitrary MFL expressions.

Built-in Function: void header_insert (string name,   string value, number idx)

This function is equivalent to header_add with three arguments, i.e. it inserts a header ‘name: ‘value’ at idxth header position in the message.

Built-in Function: void header_delete (string name   [, number index])

Delete header name from the envelope. If index is given, delete indexth instance of the header name.

Notice the differences between this function and the delete action:

  1. It allows to construct the header name, whereas delete requires it to be a literal string.
  2. Optional index argument allows to select a particular header instance to delete.
Built-in Function: void header_replace (string name,   string value [, number index])

Replace the value of the header name with value. If index is given, replace indexth instance of header name.

Notice the differences between this function and the replace action:

  1. It allows to construct the header name, whereas replace requires it to be a literal string.
  2. Optional index argument allows to select a particular header instance to replace.