Answer the question
In order to leave comments, you need to log in
How to return only text when reading response from boost beast site?
#include "stdafx.h"
#include <boost/beast.hpp>
#include <boost/asio/connect.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <Windows.h>
namespace http = boost::beast::http;
int main()
{
const std::string host = "ahri9fox.online";
//const std::string target = "/chat/chat.php?request=check";
const std::string target = "/chat/messages.txt";
boost::asio::io_context ioc;
boost::asio::ip::tcp::resolver resolver(ioc);
boost::asio::ip::tcp::socket socket(ioc);
boost::asio::connect(socket, resolver.resolve(host, "80"));
http::request<http::string_body> req(http::verb::get, target, 11);
req.set(http::field::host, host);
req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING);
http::write(socket, req);
{
boost::beast::flat_buffer buffer;
http::response<http::dynamic_body> res;
http::read(socket, buffer, res);
std::cout << res << std::endl;
}
socket.shutdown(boost::asio::ip::tcp::socket::shutdown_both);
system("pause");
return 0;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question