The following example modifies an existing response object by adding a header to it:
<AssignMessage name="AM-modify-response"> <Set> <Headers> <Header name="Cache-Hit">{lookupcache.LookupCache-1.cachehit}</Header> </Headers> </Set> <IgnoreUnresolvedVariables>false </IgnoreUnresolvedVariables> <AssignTo>response</AssignTo> </AssignMessage>
This example does not create a new message. Instead, it modifies an existing response message by adding an HTTP header.
Because this example specifies response
as the variable name in the
<AssignTo>
element, this policy modifies the response object that was originally
set with data returned by the target server.
The HTTP header added to the response message by this policy is derived from a variable populated by the LookupCache policy. Therefore the response message modified by this Assign Message policy contains an HTTP header that indicates whether the results have been pulled from the cache or not. Setting headers in the response can be handy for debugging and troubleshooting.