The http response from the server contains such headers.
Set-Cookie: A=AValue
Set-Cookie: B=BValue
When I try to get the values from Fiddler script using following code:
oSession.oResponse["Set-Cookie"]
I only get the first one, A=AValue.
Do you know how to get the full list of these values even if the keys are duplicated?
You can use the headers
property off oResponse
to get the full collection, then enumerate through each and find them. In C#:
var headers = oSession.oResponse.headers.Where(h => h.Name == "Set-Cookie").ToList();
Here is how you can do it in JScript.NET (Fiddler Script):
var headers = [];
var enumerator = oSession.oResponse.headers.GetEnumerator();
while(enumerator.MoveNext()) {
var current = enumerator.Current;
if (current.Name.ToLower() === "set-cookie") {
headers.push(current.Value);
}
}
enumerator.Dispose();
To explain, this loops over all of the headers, checks the name, and if the name of the header matches, it pushes the value into the headers
array. After while
loop, the headers
array will contain all of the values for the Set-Cookie
headers.