To Apply Header Injection and Removal Policies (Mule 4)
Supported runtimes: Mule Runtime 4.1.0 and later.
The Header Injection policy adds headers to the request/response of the message. The Header Removal policy removes all listed headers.
To apply this policy to an API, specify an inbound/outbound map of the headers that you want to add in the message processing in the form of a key-value pair.
If the injected header already exists in the message attributes, the policy creates a new header, without overriding the value of the existing one. This action creates two headers with the same name.
Note: Comma separated values are not considered multiple values by the Mule HTTP Connector.
You can use DataWeave expressions to set a value. For example:
To overwrite the value of a header, remove it before injecting the header.
To apply this policy to an API, specify the header names as regular expressions, separated by commas.
The content-type and content-length headers of a request can be filtered by this policy, as shown in this example, as well as the host header.
In the response, only the content-type header is removed.