|
地板
楼主 |
发表于 2013-9-22 18:06:58
|
只看该作者
我这怎么收不到数据?
[code=csharp]StringBuilder shi= new StringBuilder();
shi.Append("GET /tmp/g.php HTTP/1.1\r\n");
//shi.Append("Accept: */*");
shi.Append("Accept: image/jpeg, application/x-ms-application, image/gif, application/xaml+xml, image/pjpeg, application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*\r\n");
shi.Append("Referer: http://localhost/tmp/l.php\r\n");
shi.Append("Accept-Language: zh-CN\r\n");
shi.Append("User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E)\r\n");
shi.Append("Accept-Encoding: gzip, deflate\r\n");
shi.Append("Host: localhost\r\n");
shi.Append("Connection: Keep-Alive\r\n");
shi.Append("Cookie:"+cks);
sendMsg(shi.ToString());[/code]
然后是接收部分 ,用POST的时候能行, get 貌似吧后面的HTTP/1.1拿掉可以get得到内容,上面的这些参数都是用Httpwatch直接复制过来的- byte [] buffer = new byte[2000];
- while (!isExit)
- {
- int length = skt.Receive(buffer, 0, 2000, SocketFlags.None);
- if (length > 0)
- {
- string res = Encoding.GetEncoding("gb2312").GetString(buffer,0,length);
- showmsg("【收到数据】\r\n"+res+"\r\n",Color.LightGreen);
- getcks(res);
- showmsg("得到Cookie "+cks,Color.Red);
- }
- }
复制代码 |
|