From d02a29f0ff33279268e675aae0856f3f8cf9d939 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Tue, 10 Jan 2023 14:22:47 +0100 Subject: Configurable Websocket für HTTPS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- response.cpp | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'response.cpp') diff --git a/response.cpp b/response.cpp index 29176af..eeda8d0 100644 --- a/response.cpp +++ b/response.cpp @@ -42,7 +42,7 @@ public: // GetTarget() == GetPluginPath() + GetRelativePath() - const Path& GetPath() const {return m_path;} + const Path& GetPath() const {return m_path;} // GetPluginPath w/ configured params as struct std::string GetPluginName() const {return m_path.params.at("plugin");} // can throw std::out_of_range @@ -297,7 +297,7 @@ response_type handleAuth(RequestContext& req_ctx, response_type& res) } // anonymous namespace -response_type generate_response(request_type& req, Server& server) +response_type response::generate_response(request_type& req, Server& server) { response_type res{http::status::ok, req.version()}; res.set(http::field::server, Server::VersionString); @@ -334,3 +334,26 @@ response_type generate_response(request_type& req, Server& server) } +std::string response::get_websocket_address(request_type& req, Server& server) +{ + try { + std::cout << "DEBUG0" << std::endl; + std::cout << "DEBUG0: " << req.target() << std::endl; + RequestContext req_ctx{req, server}; // can throw std::out_of_range + + std::cout << "DEBUG1" << std::endl; + if (req_ctx.GetPluginName() != "websocket") { + std::cout << "Bad plugin configured for websocket request: " << req_ctx.GetPluginName() << std::endl; + return {}; + } + + std::cout << "DEBUG2" << std::endl; + return req_ctx.GetDocRoot(); // Configured "path" in config: host:port for websocket + std::cout << "DEBUG3" << std::endl; + + } catch (const std::exception& ex) { + std::cout << "No matching configured target websocket found: " << ex.what() << std::endl; + return {}; + } +} + -- cgit v1.2.3