Ejemplo n.º 1
0
        internal async Task <string> GetConvertedStringAsync(string url)
        {
#if DEBUG_NICO_URL
            UrlDebugHelper.DebugLog(url);
#endif
            return(await HttpClient.GetConvertedStringAsync(url));
        }
Ejemplo n.º 2
0
        internal async Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, HttpCompletionOption completionOption = HttpCompletionOption.ResponseContentRead)
        {
#if DEBUG_NICO_URL
            UrlDebugHelper.DebugLog($"[{request.Method}] {request.RequestUri.OriginalString}");
#endif

#if WINDOWS_UWP
            return(await HttpClient.SendRequestAsync(request, completionOption));
#else
            return(await HttpClient.SendAsync(request, completionOption));
#endif
        }
Ejemplo n.º 3
0
        internal async Task <string> GetStringAsync(string url)
        {
#if DEBUG_NICO_URL
            UrlDebugHelper.DebugLog(url);
#endif

#if WINDOWS_UWP
            return(await HttpClient.GetStringAsync(new Uri(url)));
#else
            return(await HttpClient.GetConvertedStringAsync(url));
#endif
        }
Ejemplo n.º 4
0
        internal async Task <HttpResponseMessage> GetAsync(string url)
        {
#if DEBUG_NICO_URL
            UrlDebugHelper.DebugLog(url);
#endif

#if WINDOWS_UWP
            return(await HttpClient.GetAsync(new Uri(url)));
#else
            return(await HttpClient.GetAsync(url));
#endif
        }
Ejemplo n.º 5
0
        internal async Task <string> PostAsync(string url, HttpContent content)
#endif
        {
#if DEBUG_NICO_URL
            UrlDebugHelper.DebugLog(url);
#endif

            using (var res = await HttpClient.PostAsync(new Uri(url), content))
            {
                if (res.IsSuccessStatusCode)
                {
                    return(await res.Content.ReadAsStringAsync());
                }
                else
                {
                    System.Diagnostics.Debug.WriteLine(res.ToString());
                    return("");
                }
            }
        }
Ejemplo n.º 6
0
        internal async Task <string> PostAsync(string url, Dictionary <string, string> keyvalues, bool withToken = true)
        {
#if DEBUG_NICO_URL
            UrlDebugHelper.DebugLog(url);
#endif

            if (withToken && !keyvalues.ContainsKey("token"))
            {
                var token = await this.GetToken();

                keyvalues.Add("token", token);
            }

#if WINDOWS_UWP
            var content = new HttpFormUrlEncodedContent(keyvalues);
#else
            var content = new FormUrlEncodedContent(keyvalues);
#endif


            return(await this.PostAsync(url, content));
        }