Ejemplo n.º 1
0
        public CookieCollection GetHttpsCookies()
        {
            const string registerHttpsPrepareUrlFormat =
                "https://ssl.mail.163.com/regall/unireg/prepare.jsp?sid={0}&sd={1}";

            var httpCookies = GetHttpCookies();

            if (mHttpsCookieCollection != null)
            {
                return(mHttpsCookieCollection);
            }
            var prepareUrl = string.Format(registerHttpsPrepareUrlFormat, httpCookies["jsessionid"].Value, httpCookies["ser_adapter"].Value);

            var headers = HttpRequestHelper.GetDefaultHeaders();

            headers.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
            headers.Add("Referer", "http://reg.email.163.com/unireg/call.do?cmd=register.entrance&from=163navi&regPage=163");

            var cookies = HttpRequestHelper.GenerateCookiesFromUrl(prepareUrl, null, headers);

            mHttpsCookieCollection = new CookieCollection();

            for (int i = 0; i < cookies.Count; i++)
            {
                if (!cookies[i].Secure && cookies[i].Name.ToLower().Equals("jsessionid"))
                {
                }
                else
                {
                    mHttpsCookieCollection.Add(cookies[i]);
                }
            }
            return(mHttpsCookieCollection);
        }
Ejemplo n.º 2
0
        private CookieCollection GetHttpCookies()
        {
            if (mHttpCookieCollection != null)
            {
                return(mHttpCookieCollection);
            }
            var headers = HttpRequestHelper.GetDefaultHeaders();

            headers.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");

            mHttpCookieCollection = HttpRequestHelper.GenerateCookiesFromUrl(REGISTER_PAGE_URL, null, headers);

            return(mHttpCookieCollection);
        }