Header

This policy allows you to set or delete headers to either the response or the request.
Note: Setting a header creates a new header unless it already exists, in which case it updates the existing header.

Example 1

In this example, a header is set for a request.

<header
    xmlns="http://www.infor.com/ion/api"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    name="header-example" displayName="header-example" enabled="true" version="1.0" >
    <action>set<action>  
    <headerName>x-cache</headerName>
    <headerValue>true</headerValue>
</header>

Example 2

In this example, the header value is extracted from the context.

<header name="header-example" displayName="header-example" enabled="true" >
    <action>set<action>  
    <headerName>x-cache</headerName>
    <headerValue ref='context.url.tenant'/>
</header>

In the example, reference is made to a variable in the context object. The context object is a shared dictionary of information that can be accessed from the policies.

Configuration

Element name Default Presence Type Multiplicity
action n/a Required string 1
headerName n/a Optional string 0..1
headerValue n/a Optional string 0..1

<header> attributes

<header name="header-example" displayName="header-example" enabled="true" version="1.0">
Field Name Description Default Presence
name Name of this policy instance. N/A Required

displayName

Optional
enabled Indicates if a policy is enforced or not. If set to false, a policy is turned off, and not enforced. true Optional
version Policy version N/A Required

<action> element

The action indicates the intention of this policy:

  • set: set the header value. Insert if the header does not already exist. Otherwise, update.
  • delete: remove the header. If the header name is '*', the policy deletes all the headers.
<action>set<action>

<headerName> element

Name of the affected header.

<headerName>x-cache</headerName>

<headerValue> element

Value of the header being set. This element is required only if you are setting a header.

<headerValue>true</headerValue>

The header value can also refer to a variable:

<headerValue ref="context.url.tenant"/>