92{
93 auto self(shared_from_this());
94
95 async_read_until(
socket,
buff,
'\r', [
this, self](
const boost::beast::error_code& e, std::size_t s) {
96 if (!e) {
97 std::string line, ignore;
98 std::istream stream{&
buff};
99 std::getline(stream, line, '\r');
100 std::getline(stream, ignore, '\n');
102
103 if (line.length() == 0) {
104 if (
headers.content_length() == 0) {
105 std::cout <<
"Request received: " <<
headers.method <<
" " <<
headers.get_url();
106 if (
headers.method ==
"OPTIONS") {
107
109 return;
110 }
111
113 const auto resp =
server.server.m_request_handler(url_str);
114 std::stringstream ssOut;
115 resp->write_response(ssOut);
116 std::shared_ptr<std::string> str = std::make_shared<std::string>(ssOut.str());
117 async_write(
socket, boost::asio::buffer(str->c_str(), str->length()),
118 [this, self, str](const boost::beast::error_code& e, std::size_t s) {
119 std::cout << "done" << std::endl;
120 server.stop(self);
121 });
122 } else {
124 }
125 } else {
127 }
128 } else if (e != boost::asio::error::operation_aborted) {
130 }
131 });
132}
void read_body()
Definition HttpServer.cpp:81
static std::string url_decode(const std::string &str)
Definition Http.cpp:984