为什么我得到空的回复?

时间:2014-07-01 19:52:14

标签: c# http proxy

我发送:

GET / HTTP/1.1
Host: example.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv28.0) Gecko/20100101 Firefox/28.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: de,en-US;q=0.7,en;q=0.3
Accept-Encoding: gzip, deflate
Connection: close

我的代码:

 htmlClient.Connect(Dns.GetHostAddresses(url.Host)[0], 80); // Connect to server on port 80
 htmlClient.Send(ASCIIEncoding.Default.GetBytes(htmlreq));
 byte[] htmlReqBuff = new byte[10240];
 htmlClient.Receive(htmlReqBuff);
 htmlClient.Disconnect(false);
 htmlClient.Shutdown(SocketShutdown.Both);
 htmlClient.Dispose();
 Log.info(ASCIIEncoding.Default.GetString(htmlReqBuff));

从某些Web服务器我收到请求超时。

1 个答案:

答案 0 :(得分:0)

您的请求必须以空行<CR><LF>结尾,以指示HTTP请求的结束。