Kylin/HttpProxy/ProxyHttpSession.h

28 lines
925 B
C
Raw Normal View History

2023-07-21 15:28:59 +08:00
#ifndef PROXYHTTPSESSION_H
#define PROXYHTTPSESSION_H
#include <boost/beast/core/flat_buffer.hpp>
#include <boost/beast/core/tcp_stream.hpp>
#include <boost/beast/http/parser.hpp>
#include <boost/beast/http/string_body.hpp>
#include <optional>
class ProxyHttpSession : public std::enable_shared_from_this<ProxyHttpSession> {
public:
ProxyHttpSession(boost::asio::io_context &ioContext, boost::asio::ip::tcp::socket &&socket);
void run();
protected:
void doRead();
void onRead(boost::beast::error_code ec, std::size_t);
private:
boost::asio::ip::tcp::resolver m_resolver;
std::optional<boost::beast::http::request_parser<boost::beast::http::string_body>> m_parser;
2023-12-29 19:10:38 +08:00
boost::beast::flat_buffer m_buffer{std::numeric_limits<std::uint32_t>::max()};
2023-07-21 15:28:59 +08:00
boost::beast::tcp_stream m_clientStream;
boost::beast::tcp_stream m_serverStream;
};
#endif // PROXYHTTPSESSION_H