This article describes how to remove an empty "set-cookie" token from header using NetScaler rewrite feature.
There are two set-cookie in header, one with empty token which needs to be removed:
10583 65.877740632 10.100.0.130 10.10.12.149 HTTP 288 HTTP/1.1 302 Found (text/html) Hypertext Transfer Protocol HTTP/1.1 302 Found\r\n Cache-Control: private\r\n Content-Length: 161\r\n Content-Type: text/html; charset=utf-8\r\n Location: https://aaronli.xsxd.local/default.aspx\r\n Server: Microsoft-IIS/7.5\r\n X-AspNet-Version: 2.0.50727\r\n Set-Cookie: MSCRMSession=ticket=PAA/AHgAbQBsACAAdgBlAHIAcwBpAG8AbgA9ACIAMQAuADAAIgA/AD4ADQAKADwAVABpAGMAawBlAHQAIAB4AG0AbABuAHMAOgB4AHMAaQA9ACIAaAB0AHQAcAA6AC8ALwB3AHcAdwAuAHcAMwAuAG8AcgBnAC8AMgAwADAAMQAvAFgATQBMAFMAYwBoAGUAbQB X-UA-Compatible: IE=EmulateIE7\r\n Date: Wed, 08 Feb 2017 02:22:30 GMT\r\n Set-Cookie: MSCRMSession=ticket=; expires=Sun, 08-Jan-2017 02:22:31 GMT; path=/\r\n \r\n [HTTP response 2/168] [Time since request: 0.061178776 seconds] [Prev request in frame: 10550] [Prev response in frame: 10556] [Request in frame: 10557] [Next request in frame: 10585] [Next response in frame: 10589] File Data: 161 bytes
The solution is remove empty set-cookie header:
add rewrite action act1 delete q/http.REs.FULL_HEADER.REGEX_SELECT(re!Set-Cookie: MSCRMSession=ticket=;.*?\r\n!)/
add rewrite policy rw1 "http.REs.SET_COOKIE.COOKIE(\"MSCRMSession \").VALUE(\"MSCRMSession \").EQ(\"ticket=\")" act1