Hi Team,
I have a requirement of replacing/adding domain in set-cookie header coming in response from target server and sending the modified set-cookie header to my front-end system.
Set-Cookie value from target -server:
securityStatus=0; expires=Tue,30-Jan-2018 06:37:25 GMT; path=/,cartCount=0; expires=Thu,01-Mar-2018 06:22:25 GMT; path=/
Problem statement:
While trying to fetch all the set-cookie by parsing this array we were not able to split above cookie splitted on basis of comma since comma is also present in expires so it is parsing incorrectly.
While we have found a way by which atleast we can fetch cookie correctly and have correct set-cookie[1],set-cookie[2] and so on but when i try to set the set-cookie in proxy response then it again parses the cookie based on comma present in expires and set in correct set-cookie response .
Below is the snippet of code being used for setting the set-cookie response while iterating over splitted cookie:
for(var i = 0; i < transformedCookieData.length; i++) { context.setVariable('message.header.set-cookie.' + i, transformedCookieData[i]); }