I am trying to develop a custom policy for my client. Everything works fine, but when I try to capture headers list from the response message, it always comes as empty - Headers:[]. The logger statement below prints the complete "message" structure, but headers always empty.
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:http-policy="http://www.mulesoft.org/schema/mule/http-policy"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http-policy http://www.mulesoft.org/schema/mule/http-policy/current/mule-http-policy.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd">
<http-policy:proxy name="{{{policyId}}}-custom-policy">
<http-policy:source>
<http-policy:execute-next/>
<logger level="INFO" message="#message" />
</http-policy:source>
</http-policy:proxy></mule>
The output in logs:
{ payload=org.mule.runtime.core.internal.streaming.bytes.ManagedCursorStreamProvider@4180b81f
mediaType=application/json; charset=UTF-8
attributes=org.mule.extension.http.api.HttpResponseAttributes
{
Status Code=200
Reason Phrase=null
Headers=[]
}
attributesMediaType=*/*
}
The API does return Headers as expected, when debugged in Anypoint Studio.
Any idea?
Thanks!