summaryrefslogtreecommitdiffhomepage
path: root/https.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'https.cpp')
-rw-r--r--https.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/https.cpp b/https.cpp
index ce3a6fd..5d19d5b 100644
--- a/https.cpp
+++ b/https.cpp
@@ -56,13 +56,13 @@ class session : public std::enable_shared_from_this<session>
beast::flat_buffer buffer_;
Server& m_server;
std::optional<http::request_parser<http::string_body>> parser_; // need to reset parser every time, no other mechanism currently
- http::request<http::string_body> req_;
+ request_type req_;
std::shared_ptr<response_type> res_; // std::shared_ptr<void>
- void handle_request(::Server& server, request_type&& req)
+ void handle_request()
{
beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(300)); // timeout on write by server much longer than read timeout from client
- auto sp = std::make_shared<response_type>(generate_response(req, server));
+ auto sp = std::make_shared<response_type>(response::generate_response(req_, m_server));
res_ = sp;
@@ -75,6 +75,13 @@ class session : public std::enable_shared_from_this<session>
shared_from_this(),
sp->need_eof()));
}
+
+ void handle_websocket()
+ {
+ beast::get_lowest_layer(stream_).expires_never();
+ std::make_shared<websocket_session>(ioc_, std::move(stream_), response::get_websocket_address(req_, m_server))->do_accept_in(parser_->release());
+ }
+
public:
// Take ownership of the socket
explicit
@@ -171,13 +178,12 @@ public:
if (websocket::is_upgrade(req_))
{
- beast::get_lowest_layer(stream_).expires_never();
- std::make_shared<websocket_session>(ioc_, std::move(stream_))->do_accept_in(parser_->release());
+ handle_websocket();
return;
}
// Send the response
- handle_request(m_server, std::move(req_));
+ handle_request();
}
void