FlickrNet.TwitterResponder.DownloadDataAsync C# (CSharp) Méthode

DownloadDataAsync() private static méthode

private static DownloadDataAsync ( string method, string baseUrl, string data, string contentType, string authHeader ) : Task>
method string
baseUrl string
data string
contentType string
authHeader string
Résultat Task>
        private async static Task<FlickrResult<string>> DownloadDataAsync(string method, string baseUrl, string data, string contentType, string authHeader)
        {
            int retryCounter = 0;

            retry:

            FlickrResult<string> ret = new FlickrResult<string>();

            string useUrl = baseUrl;
            if (method == "GET" && data.Length > 0) useUrl += "?" + data;

            HttpClient client = new HttpClient();
            //todo: what is the equivalent of this call in windows.web.http
            //client.MaxResponseContentBufferSize = 10 * 1024 * 1024;
            


            client.DefaultRequestHeaders.Add("HTTP_USER_AGENT", Flickr.UserAgent);

            //if (!String.IsNullOrEmpty(contentType) && method != "GET") 
            //    client.DefaultRequestHeaders.Add("Content-Type", contentType);

            if (!String.IsNullOrEmpty(authHeader))
                client.DefaultRequestHeaders.Add("Authorization", authHeader);

            try
            {


                HttpResponseMessage httpRM = new HttpResponseMessage();

                if (method == "POST")
                {
                    var content = new HttpStringContent(data);
                    httpRM = await client.PostAsync(new Uri(useUrl), content);
                }
                else if (method == "GET")
                {
                    httpRM = await client.GetAsync(new Uri(useUrl));
                }

                if (httpRM.IsSuccessStatusCode)
                {
                    ret.Result = await httpRM.Content.ReadAsStringAsync();
                    ret.HasError = false;
                }
                else
                {
                    retryCounter++;
                    if (retryCounter == 2)
                    {
                        retryCounter = 0;
                        ret.HasError = true;
                        ret.ErrorCode = (int)httpRM.StatusCode;
                        ret.ErrorMessage = httpRM.StatusCode.ToString();
                    }
                    else
                    {
                        goto retry;
                    }
                }

            }
            catch (Exception ex)
            {
                retryCounter++;
                if (retryCounter == 2)
                {
                    retryCounter = 0;
                    ret.HasError = true;
                    ret.ErrorCode = -999;
                    ret.ErrorMessage = ex.Message;
                    ret.Error = ex;
                }
                else
                {
                    goto retry;
                }
            }

            return ret;

        }