我的问题是两个不同的回答。
我的部分代码会发送请求。
boost::asio::ip::tcp::iostream stream;
stream.expires_from_now(boost::posix_time::seconds(60));
stream.connect("www.mail.ru","http");
stream << "GET /cgi-bin/msglist HTTP/1.1\r\n";
stream << "Host: e.mail.ru\r\n";
stream << "Connection: keep-alive\r\n";
stream << "User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.57 Safari/536.11\r\n";
stream << "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n";
stream << "Referer: http://mail.ru/ \r\n";
stream << "Accept-Encoding: gzip,deflate,sdch\r\n";
stream << "Accept-Language: en-US,en;q=0.8\r\n";
stream << "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3\r\n";
stream << "Cookie: Cookie here \r\n\r\n";
Such a response from the server I get from the code
HTTP/1.1 302 OK
Date: Fri, 13 Jul 2012 19:00:06 GMT
Server: Apache/1.3.27 (Unix) mru_xml/0.471 gorgona/2.1 mod_jk/1.2.4 mod_ruby/1.0.7 Ruby/1.6.8 mod_mrim/0.17
Connection: close
Location: http://e.mail.ru/cgi-bin/msglist
Content-Length: 0
Content-Type: text/plain
但是当我从浏览器用相同的标题做同样的请求时,我得到了
此回复
//HTTP/1.1 200 OK
//Server: nginx/0.7.62
//Date: Fri, 13 Jul 2012 18:50:46 GMT
///Content-Type: text/html; charset=utf-8
//Connection: close
//P3P: CP="NON CUR OUR IND UNI INT"
//Cache-Control: no-cache,no-store,must-revalidate
//Pragma: no-cache
//Expires: Thu, 14 Jul 2011 18:50:46 GMT
//Last-Modified: Fri, 13 Jul 2012 22:50:46 GMT
//X-Host: f306.mail.ru
//Content-Length: 461042
所以我的代码有什么问题?(我需要从我的代码中获得响应200)