After spending some time looking for an out-of-the-box solution, I ended implementing an extension method to System.Net.WebHeaderCollection:
public static class WebHeaderCollectionExtensions
{
public static ILookup<string, string> ToLookup(this WebHeaderCollection some)
{
List<KeyValuePair<string, string>> headers = new List<KeyValuePair<string, string>>();
if (some.Count > 0)
{
string[] tempSplittedHeaders = null;
foreach (string headerName in some)
{
if (some[headerName].Contains(";,"))
{
tempSplittedHeaders = Regex.Split(some[headerName], ";,");
foreach (string splittedHeader in tempSplittedHeaders)
{
headers.Add(new KeyValuePair<string, string>(headerName, splittedHeader));
}
}
else
{
headers.Add(new KeyValuePair<string, string>(headerName, some[headerName]));
}
}
}
return headers.ToLookup(keySelector => keySelector.Key, elementSelector => elementSelector.Value);
}
}
Thanks to this wonderful extension method, I'm able to convert headers' collection to a lookup, which allows duplicate keys, and at the end of the day, doing some processing, I get a list of all HTTP headers in separately:
string wholeCookie = WebOperationContext.Current.IncomingRequest.Headers.ToLookup()["Set-Cookie"].Single(cookie => cookie.Contains("[Cookie name]"));
I hope sharing my solution will be a good contribution, as I guess others had or are having a similar case use!