public DownloadStringAsync ( string url, long bufferSize = 8192, Encoding encoding = null ) : Task |
||
url | string | |
bufferSize | long | Internal download buffer size used to hold data chunks. |
encoding | Encoding | A .NET Encoding scheme or null to attempt sniffing from Charset. |
리턴 | Task |
public async Task PlainHTtpRequest() { var client = new HttpClient(); string result = await client.DownloadStringAsync("http://west-wind.com"); Console.WriteLine(result); }
public async Task HttpTimingsTestsAsync() { var client = new HttpClient(); var html = await client.DownloadStringAsync("http://weblog.west-wind.com/posts/2015/Jan/06/Using-Cordova-and-Visual-Studio-to-build-iOS-Mobile-Apps"); Console.WriteLine(client.WebResponse.ContentLength); Console.WriteLine(client.HttpTimings.StartedTime); Console.WriteLine("First Byte: " + client.HttpTimings.TimeToFirstByteMs); Console.WriteLine("Last Byte: " + client.HttpTimings.TimeToLastByteMs); }
public async void HttpTimingsTestsAsync() { var client = new HttpClient(); var html = await client.DownloadStringAsync("http://weblog.west-wind.com/posts/2015/Jan/06/Using-Cordova-and-Visual-Studio-to-build-iOS-Mobile-Apps"); Console.WriteLine(client.WebResponse.ContentLength); Console.WriteLine(client.HttpTimings.StartedTime); Console.WriteLine("First Byte: " + client.HttpTimings.TimeToFirstByteMs); Console.WriteLine("Last Byte: " + client.HttpTimings.TimeToLastByteMs); Thread.Sleep(2000); }
async Task<int> RunHttpRequestAsync() { using (var client = new HttpClient()) { client.CreateWebRequestObject(testUrl); string result = await client.DownloadStringAsync(testUrl); } Interlocked.Increment(ref counter); return 0; }