示例#1
0
        public static string GetCookieByHead(string sInput)
        {
            List <string> list = CRegex.GetList(CRegex.GetText(sInput, @"Set-Cookie:(?<Cookie>[\s\S]+?)\n", "Cookie"), @"(?<cookie>[\w\d\.]+=[\w\d\._-]+);", "cookie");
            string        str2 = "";

            foreach (string str3 in list)
            {
                str2 = str2 + str3 + "; ";
            }
            return(str2);
        }
示例#2
0
        public static List <CookieObj> GetCookieList(string sInput, List <CookieObj> listInput)
        {
            List <string>    list  = CRegex.GetList(CRegex.Replace(CRegex.GetText(sInput, @"Set-Cookie:(?<Cookie>[\s\S]+?)\n", "Cookie"), "expires=([^;]+)GMT;", "", 0).Replace("path=/", ""), @"(?<cookie>[\w\d\&\.=]+[\w\d\._-]+);", "cookie");
            CookieObj        item  = null;
            List <CookieObj> list2 = new List <CookieObj>();

            foreach (string str4 in list)
            {
                if (str4.IndexOf('=') >= 1)
                {
                    string str2 = str4.Substring(0, str4.IndexOf('='));
                    if (str2 != "domain")
                    {
                        string str3;
                        if (str4.Length < (str4.IndexOf('=') + 1))
                        {
                            str3 = "";
                        }
                        else
                        {
                            str3 = str4.Substring(str4.IndexOf('=') + 1);
                        }
                        item = new CookieObj
                        {
                            cookieName  = str2,
                            cookieValue = str3
                        };
                        list2.Add(item);
                    }
                }
            }
            foreach (CookieObj obj4 in list2)
            {
                bool flag = false;
                for (int i = 0; i < listInput.Count; i++)
                {
                    CookieObj obj3 = listInput[i];
                    if (obj3.cookieName == obj4.cookieName)
                    {
                        flag             = true;
                        obj3.cookieValue = obj4.cookieValue;
                    }
                }
                if (!flag)
                {
                    listInput.Add(obj4);
                }
            }
            return(listInput);
        }