Modified Extract Cookie to use the built in cookie parser instead.
Showing
1 changed file
with
4 additions
and
13 deletions
... | @@ -130,26 +130,17 @@ namespace LIL_VSTT_Plugins | ... | @@ -130,26 +130,17 @@ namespace LIL_VSTT_Plugins |
130 | 130 | ||
131 | public override void Extract(object sender, ExtractionEventArgs e) | 131 | public override void Extract(object sender, ExtractionEventArgs e) |
132 | { | 132 | { |
133 | WebHeaderCollection col = e.Response.Headers; | 133 | foreach (Cookie ck in e.Response.Cookies) |
134 | foreach (string h in col.Keys) | ||
135 | { | 134 | { |
136 | if(h.Equals("Set-Cookie")) | 135 | if(ck.Name.Equals(cookieName)) |
137 | { | 136 | { |
138 | string[] cookie = col[h].Split('='); | 137 | e.WebTest.Context.Add(this.ContextParameterName, WebUtility.UrlDecode(ck.Value)); |
139 | if(cookie[0].Equals(cookieName)) | ||
140 | { | ||
141 | string value = ""; | ||
142 | if (cookie.Length > 1) | ||
143 | { | ||
144 | value = cookie[1].Split(';')[0]; | ||
145 | } | ||
146 | e.WebTest.Context.Add(this.ContextParameterName, WebUtility.UrlDecode(value)); | ||
147 | e.Success = true; | 138 | e.Success = true; |
148 | e.Message = "Cookie found"; | 139 | e.Message = "Cookie found"; |
149 | return; | 140 | return; |
150 | } | 141 | } |
151 | } | 142 | } |
152 | } | 143 | |
153 | e.Success = false; | 144 | e.Success = false; |
154 | e.Message = "Cookie not found"; | 145 | e.Message = "Cookie not found"; |
155 | } | 146 | } | ... | ... |
-
Please register or sign in to post a comment