public void LogonTest() { IList <Cookie> cookies = Authentication.AuthenticationManager.Current.CookieCache; Assert.IsTrue(cookies != null); Console.WriteLine("Count:{0}", cookies.Count); foreach (Cookie cookie in cookies) { Console.WriteLine("Index:{0}", cookies.IndexOf(cookie)); Console.WriteLine("\tDomain:{0}", cookie.Domain); Console.WriteLine("\tName:{0}", cookie.Name); string value = cookie.Value; if (cookie.Name.ToLower() == "cadata") { byte[] content = Convert.FromBase64String(value.Substring(1, value.Length - 2)); Encoding encoding = TextFileEncodingDetector.DetectTextByteArrayEncoding(content); //Encoding.GetEncoding("gzip"); if (encoding != null) { value = encoding.GetString(content); Console.WriteLine("\tBase64 Value:{0}", cookie.Value); } } Console.WriteLine("\tValue:{0}", value); Console.WriteLine("\tPort:{0}", string.IsNullOrEmpty(cookie.Port)?"N/A":cookie.Port); Console.WriteLine("\tPath:{0}", string.IsNullOrEmpty(cookie.Port) ? "N/A" : cookie.Path); Console.WriteLine("\tHttpOnly:{0}", cookie.HttpOnly); Console.WriteLine("\tComment:{0}", string.IsNullOrEmpty(cookie.Port) ? "N/A" : cookie.Comment); } Assert.IsTrue(cookies.Count != 0); }
public void InitBytes(byte[] bytes, EncodingPair defaultEncoding, out string error) { error = null; string text = ""; encodingPair = defaultEncoding; if (bytes != null) { try { if (!settedEncodingPair.IsNull) { encodingPair = settedEncodingPair; } else { bool bom; Encoding encoding = TextFileEncodingDetector.DetectTextByteArrayEncoding(bytes, out bom); if (encoding != null) { encodingPair = new EncodingPair(encoding, bom); } } int bomLength = encodingPair.CorrectBomLength(bytes); if (encodingPair.bom && encodingPair.encoding == Encoding.UTF8 && bomLength == 0) { encodingPair = new EncodingPair(Encoding.UTF8, false); settedEncodingPair = encodingPair; if (error == null) { error = "Missing bom, loaded as without it"; } } text = encodingPair.GetString(bytes, bomLength); } catch (Exception e) { error = e.Message; } } if (encodingPair.IsNull) { encodingPair = new EncodingPair(Encoding.UTF8, false); } Controller.InitText(text); }