-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.cs
37 lines (32 loc) · 839 Bytes
/
Main.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System;
using System.IO;
using System.Net;
using System.Threading;
namespace WebTest
{
class MainClass
{
public static void Main (string[] args)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.google.com/");
HttpWebResponse response;
// response = (HttpWebResponse)request.GetResponse();
IAsyncResult asyncResult = request.BeginGetResponse(null, null);
Console.Write("Waiting...");
while (!asyncResult.IsCompleted)
{
Console.Write(".");
Thread.Sleep(500);
}
Console.WriteLine();
response = (HttpWebResponse)request.EndGetResponse(asyncResult);
using (Stream responseStream = response.GetResponseStream())
{
using (TextReader reader = new StreamReader(responseStream))
{
Console.WriteLine(reader.ReadToEnd());
}
}
}
}
}