2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
42#include "web/http/server/SocketContextUpgradeFactorySelector.h"
44#include "web/http/SocketContextUpgradeFactorySelector.hpp"
45#include "web/http/server/Request.h"
47#ifndef DOXYGEN_SHOULD_SKIP_THIS
50#include "log/Logger.h"
55#include "web/http/http_utils.h"
61namespace web::http::
server {
65 std::string httpUpgradeInstallLibdir = HTTP_UPGRADE_INSTALL_LIBDIR;
68 if (
const char* httpUpgradeInstallLibdirEnv = std::getenv(
"HTTP_UPGRADE_INSTALL_LIBDIR")) {
69 LOG(WARNING) <<
"HTTP: Overriding http upgrade library dir";
70 httpUpgradeInstallLibdir = std::string(httpUpgradeInstallLibdirEnv);
74 return load(socketContextUpgradeName,
75 httpUpgradeInstallLibdir +
"/libsnodec-" + socketContextUpgradeName +
"-server.so." SOVERSION,
76 socketContextUpgradeName +
"ServerSocketContextUpgradeFactory");
82 return &socketContextUpgradeFactorySelector;
86 SocketContextUpgradeFactory* socketContextUpgradeFactory =
nullptr;
88 std::string upgradeContextNames = req
.get("upgrade");
90 while (!upgradeContextNames.empty() && socketContextUpgradeFactory ==
nullptr) {
91 std::string upgradeContextName;
92 std::string upgradeContextVersion;
100 socketContextUpgradeFactory =
select(upgradeContextName
);
103 if (socketContextUpgradeFactory !=
nullptr) {
107 return socketContextUpgradeFactory;
SocketContextUpgradeFactory * select(const std::string &socketContextUpgradeName)
void prepare(Request &request, Response &response)
const std::string & get(const std::string &key, int i=0) const
SocketContextUpgradeFactory * select(Request &req, Response &res) override
static SocketContextUpgradeFactorySelector * instance()
SocketContextUpgradeFactory * load(const std::string &socketContextUpgradeName) override
std::string::iterator to_lower(std::string &string)
std::pair< std::string, std::string > str_split(const std::string &base, char c_middle)
std::string & str_trimm(std::string &text)