Ejemplo n.º 1
0
        public static Cookie Parse(string value)
        {
            var cookie = new Cookie();
            foreach (var pair in HeaderStore.ParseMultiValue(value, ';'))
            {
                var eq = pair.IndexOf('=');
                if (eq == -1)
                {
                    cookie.Add(pair, Cookie.AttributeOnly);
                    continue;
                }

                cookie.Add(pair.Substring(0, eq).Trim(), pair.Substring(eq + 1).Trim());
            }

            return cookie;
        }
Ejemplo n.º 2
0
        public NRightApi(string account, string version)
        {
            // Forcing SSLv3 after RightScale upgraded cert to V3 on April 14th 2010
            ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Ssl3;

            // Set default values for public properties
            ApiVersion = version;
            ApiUrl = "https://my.rightscale.com/api/acct/";
            SessionCookie = new Cookie();

            // Initialize static HTTPClient
            Account = account;
            HttpClient = new HttpClient
            {
                BaseAddress = new Uri(ApiUrl + Account + "/"),
                TransportSettings = { MaximumAutomaticRedirections = 0 }
            };

            // Add API version to HttpClient
            HttpClient.DefaultHeaders.Add("X-API-VERSION: " + ApiVersion);
        }