//调用示例:
private void button1_Click(object sender, System.EventArgs e)
{
HttpRequestResponse xx = new HttpRequestResponse();
xx.DataArrival += new DataArrivalEventHandler(xx_DataArrival);
xx.SendRequest("http://www.triaton.com.cn/dotnet/tree/index.asp","userid=老","Post");
xx.SendRequest("http://www.triaton.com.cn/dotnet/tree/index.asp","userid=老","get");
}
private void xx_DataArrival(object sender, DataArrivalEventArgs e)
{
Console.WriteLine(e.RecievedData);
Console.WriteLine(e.IsComplete);
}
//========================
//Class1.cs
using System;
using System.Net;
using System.Threading;
using System.Text;
using System.IO;
public class RequestState
{
const int BUFFER_SIZE = 1024;
public System.Text.StringBuilder RequestData;
public byte[] BufferRead;
public System.Net.HttpWebRequest Request;
public System.IO.Stream ResponseStream;
public System.Text.Decoder StreamDecode = System.Text.Encoding.GetEncoding("gb2312").GetDecoder();
public RequestState()
{
BufferRead = new byte[BUFFER_SIZE];