BaconographyW8.PlatformServices.SimpleHttpService.SendPostForCookies C# (CSharp) Method

SendPostForCookies() public method

public SendPostForCookies ( string>.Dictionary urlEncodedData, string uri ) : Task>>
urlEncodedData string>.Dictionary
uri string
return Task>>
        public async Task<Tuple<string, Dictionary<string, string>>> SendPostForCookies(Dictionary<string, string> urlEncodedData, string uri)
        {
            //limit requests to once every 500 milliseconds
            await ThrottleRequests();
            var getMeClientHandler = new HttpClientHandler { CookieContainer = new CookieContainer() };

            var postClient = new HttpClient(getMeClientHandler);
            postClient.DefaultRequestHeaders.UserAgent.Add(new System.Net.Http.Headers.ProductInfoHeaderValue("Baconography_Windows_8_Client", "1.0"));
            var postResult = await postClient.PostAsync(uri, new FormUrlEncodedContent(urlEncodedData));

            if (postResult.IsSuccessStatusCode)
            {
                var jsonResult = await postResult.Content.ReadAsStringAsync();

                var loginCookies = getMeClientHandler.CookieContainer.GetCookies(new Uri(uri));
                var loginCookie = loginCookies["reddit_session"].Value;

                return Tuple.Create(jsonResult, new Dictionary<string, string> { {"reddit_session", loginCookie} });
            }
            else
                throw new Exception(postResult.StatusCode.ToString());
        }