AnsweredAssumed Answered

Custom Assertion accessing request/response headers

Question asked by tonysve on Oct 28, 2015
Latest reply on Oct 29, 2015 by tonysve

Hi,

 

I have a question regarding the Custom Assertion SDK.

Is there a way to access the headers on a request and response message that are added by assertions within my policy?


In a custom assertion, we read the request and response headers using the CustomPolicyContext by calling the

CustomPolicyContext.getMessage method in an extension of the ServiceInvocation checkRequest method.

 

E.g: context.getMessage("request").getKnob(CustomHttpHeadersKnob.class).getHeaderNames()

 

Request headers that are set from the client are accessible this way, but we can't see any additional headers that are set on the request or response with a "Manage Transport Properties/Headers" assertion in the executing policy.

It seems like the message retrieved by the getMessage("request") or getMessage("response") are not the actual updated messages at the execution point of my custom assertion.

When using the Service Debugger in the Policy Manager, I can see that the headers are added to the request and response, but in my custom assertion they are not.

 

I don't know the names of the headers, so I must be able to use the knob.getHeaderNames() and loop it with getHeaderValues() accordingly or a similar approach.

 

Thanks,

Tony

Outcomes