Header Removal Policy
In this tutorial we will demonstrate how can we apply the Header Removal Policy In Mule using API manager. API Manager supports policies for removing HTTP headers from a request or response. The policies take effect before sending the request or response. The Header Removal policy performs the following actions:
- Prevents receipt of one or more specified headers sent from the client to the backend service.
- Prevents inclusion of one or more specified headers in a response from the backend service to the client.
To Start with we will create an mule application and connect it with API manager – please see how we can connect the mulesoft application to API Manager
After deployment in Cloudhub the Status of the API will be Active
Now we will apply the policy
Select Header Removal
Now update the policy configuration
Have to add following
- Inbound Header Map – header key in String or Regex
- Outbound Header Map – header key in String or Regex
Lets add the required header we want to remove
Click apply
Now if I hit this API with inHeader as HTTP header
We can see the inHeader is removed from HTTP request’s headers
Hi! Thanks for the post. I am trying to use the same policy in my API but is not working. The header still gets passed in the request. Would you be able to help here?
Thanks in advance!
Please do let us know what’s the header name and the expression you are adding in the policy?
The header I want to remove is Content-Type. In some GET requests, the client is sending the content type header. So I want to remove it before processing the message. In the policy, I have mentioned it as content-type. I have also tried with Content-Type. I tried the same with a testheader. Even that is not working for me.
This cannot remove “content-type” as per mulesoft documentation.
Check– https://docs.mulesoft.com/gateway/1.4/policies-included-header-removal