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

Header Removal Policy In Mule

 

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

Header Removal Policy In Mule

 

Click apply

 

Now if I hit this API with inHeader as HTTP header

Header Removal Policy In Mule

 

We can see the inHeader is removed from HTTP request’s headers

Header Removal Policy In Mule

 

  
Thank you for taking out time to read the above post. Hope you found it useful. In case of any questions, feel free to comment below. Also, if you are keen on knowing about a specific topic, happy to explore your recommendations as well.
 
For any latest updates or posts on our website, you can follow us on LinkedIn. Look forward to connecting with you there.


Share this:
Subscribe
Notify of
guest
4 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Madhu Agarwal
Madhu Agarwal
3 years ago

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!

Last edited 3 years ago by Madhu Agarwal
Madhu Agarwal
Madhu Agarwal
3 years ago
Reply to  admin

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.

Last edited 3 years ago by Madhu Agarwal
Mule Trails
11 months ago
Reply to  Madhu Agarwal

This cannot remove “content-type” as per mulesoft documentation.

Check– https://docs.mulesoft.com/gateway/1.4/policies-included-header-removal