1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| Console.WriteLine ("preparation de la requete" + new Uri(url));
httpReq = (HttpWebRequest)HttpWebRequest.Create(new Uri(url));
// Requête http
httpReq.BeginGetResponse ((ar) => {
var request = (HttpWebRequest)ar.AsyncState;
using (var response = (HttpWebResponse)request.EndGetResponse (ar)) {
var s = response.GetResponseStream ();
Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
StreamReader readStream = new StreamReader( s, encode );
Char[] read = new Char[256];
int count = readStream.Read( read, 0, 256 );
while (count > 0)
{
String str = new String(read, 0, count);
Console.Write(str);
count = readStream.Read(read, 0, 256);
}
}
} , httpReq); |
Partager