我有一个代码来获取 html 文件的来源,但它也得到“标题响应”或 sth。像那样(我不知道怎么称呼它)没有这个标题我怎么能得到它?
我的代码:
#include "StdAfx.h"
#include <iostream>
#include <boost/array.hpp>
#include <boost/asio.hpp>
using boost::asio::ip::tcp;
std::size_t completion(const boost::system::error_code& error, std::size_t bytes_transfered)
{
return ! error;
}
int main(int argc, char* argv[])
{
boost::asio::io_service io_service;
boost::asio::ip::address addr = boost::asio::ip::address::from_string("31.170.161.16");
boost::asio::ip::tcp::endpoint endpoint(addr, 80);
tcp::socket socket(io_service);
socket.connect(endpoint);
boost::asio::streambuf request;
std::ostream requestStream(&request);
requestStream << "GET /xD1azt4_panel/bhc.html HTTP/1.1\r\n"
<< "Connection: Keep-Alive\r\n"
<< "Host: dublersoft.hostoi.com\r\n\r\n";
boost::asio::write(socket, request);
boost::asio::streambuf respond;
boost::system::error_code ec;
boost::asio::read(socket, respond, completion, ec);
std::cout << &respond << std::endl;
getchar();
return 0;
}
结果: