Exemple #1
0
        // this one should put csrf_token in cookie
        private void Login6()
        {
            string url     = uri1.AbsoluteUri + "main.php?context=ims";
            var    headers = new Dictionary <string, string>();

            headers.Add("Accept-Encoding", "gzip, deflate");
            headers.Add("Host", uri1.Host);
            headers.Add("Accept-Language", "en-US,en;q=0.8");
            headers.Add("Upgrade-Insecure-Requests", "1");
            headers.Add("Accept", "*/*");
            var wr = Get(url, headers: headers);

            if (wr.Code != HttpStatusCode.OK)
            {
                throw new InvalidOperationException(unexpectedResult);
            }
            //var all = cc.AllCookies();
            WebUtils.AddAllCookies(cc, wr.OutHeaders, url);
            var    all        = cc.AllCookies();
            Cookie csrfCookie = all.FirstOrDefault(x => x.Name == "csrf_token");

            if (csrfCookie != null)
            {
                logged = true;
                csrf   = HttpUtility.UrlDecode(csrfCookie.Value);
            }
            //ReportMainPage();
        }