I am using Apigee/ Edge extract variables policy.
Say the header looks like:
Cookie: theme=light; sessionToken=abc123
I tried the following in extract variable proxy but it doesn't seem to work.
<Header name="Cookie"> <Pattern ignoreCase="true">theme={theme}; sessionToken={token}</Pattern> </Header>
Does the sequence of parameters (theme, sessionToken) matter? How about extra spaces, do I need to account for that?
Solved! Go to Solution.
Hi @Gagan Arora, @David Allen's answer prints all headers. Here is the JavaScript code to parse the Cookie header into variables (like cookie.theme and cookie.sessionToken), using David's pattern:
var cookieHeaderStr = context.getVariable("request.header.Cookie"); cookieHeaderStr.split("; ").forEach(function(cookieStr) { if (cookieStr) { var sections = cookieStr.split("="); // set variable for each cookie context.setVariable("cookie." + sections[0], sections[1]); } });