Cshap 使用http发起请求.

 

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
using  System;
using  System.IO;
using  System.Net;
using  System.Collections.Generic;
using  System.Linq;
using  System.Text;
namespace  webclient
{
     class  Program
     {
         static  void  Main( string [] args)
         {          
             string  url = "http://v010.test.s.qq.com/Login.php" ;
             WebRequest request = WebRequest.Create(url);
             request.Credentials = CredentialCache.DefaultCredentials; // 拿到一个请求         
             HttpWebResponse response = (HttpWebResponse)request.GetResponse ();          
             Console.WriteLine (response.StatusDescription);
             Stream dataStream = response.GetResponseStream ();          
             StreamReader reader = new  StreamReader (dataStream);
             string  responseFromServer = reader.ReadToEnd ();
             Console.WriteLine (responseFromServer);          
             reader.Close ();
             dataStream.Close ();
             response.Close ();
         }
     }
}
此种方式,可以测试webgame某个重点环节。

你可能感兴趣的:(http)