AzureTicker.Worker.BL.BillProvider.ExtractResponseCookiesToCookieContainer C# (CSharp) Method

ExtractResponseCookiesToCookieContainer() private static method

private static ExtractResponseCookiesToCookieContainer ( CookieContainer &cookies, HttpWebResponse response, int cookieHeaderIndex, string cookieDomain ) : void
cookies System.Net.CookieContainer
response System.Net.HttpWebResponse
cookieHeaderIndex int
cookieDomain string
return void
        private static void ExtractResponseCookiesToCookieContainer(ref CookieContainer cookies, HttpWebResponse response, int cookieHeaderIndex, string cookieDomain)
        {
            //gets the cookies (they are set in the eleventh header)
            string[] strCookies = response.Headers.GetValues(cookieHeaderIndex);

            string name, value;
            System.Net.Cookie manualCookie;
            for (int i = 0; i < strCookies.Length; i++)
            {
                name = strCookies[i].Substring(0, strCookies[i].IndexOf("="));
                value = strCookies[i].Substring(strCookies[i].IndexOf("=") + 1, strCookies[i].IndexOf(";") - strCookies[i].IndexOf("=") - 1);
                manualCookie = new System.Net.Cookie(name, "\"" + value + "\"");

                Uri manualURL = new Uri(cookieDomain);
                cookies.Add(manualURL, manualCookie);
            }
        }