This repository has been archived on 2026-04-20. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
short-link-backend/includes/http_connection.hpp
2024-10-25 10:35:05 +02:00

37 lines
No EOL
919 B
C++

#ifndef HTTP_CONNECTION_HPP
#define HTTP_CONNECTION_HPP
#include "request_handler.hpp"
#include <boost/beast/core/flat_buffer.hpp>
#include <memory>
#include <boost/asio.hpp>
#include <boost/beast/http/string_body.hpp>
#include <boost/beast/http.hpp>
#include <boost/beast/core.hpp>
using namespace std;
using namespace boost::asio;
using namespace boost::beast;
class HttpConnection : public enable_shared_from_this<HttpConnection> {
public:
typedef shared_ptr<HttpConnection> pointer;
static pointer create(io_context& io_context);
ip::tcp::socket& socket();
void process_connection();
private:
ip::tcp::socket socket_;
boost::beast::flat_buffer buffer_;
http::request<http::string_body> request_;
http::response<http::string_body> response_;
RequestHandler request_handler_;
void read();
void write();
explicit HttpConnection(io_context& io_context);
};
#endif