42 SocketContextUpgradeFactorySelector::load(
const std::string& socketContextUpgradeName) {
43 std::string httpUpgradeInstallLibdir = HTTP_UPGRADE_INSTALL_LIBDIR;
46 if (
const char* httpUpgradeInstallLibdirEnv = std::getenv(
"HTTP_UPGRADE_INSTALL_LIBDIR")) {
47 LOG(WARNING) <<
"HTTP: Overriding http upgrade library dir";
48 httpUpgradeInstallLibdir = std::string(httpUpgradeInstallLibdirEnv);
52 return load(socketContextUpgradeName,
53 httpUpgradeInstallLibdir +
"/libsnodec-" + socketContextUpgradeName +
"-server.so." SOVERSION,
54 socketContextUpgradeName +
"ServerSocketContextUpgradeFactory");
63 SocketContextUpgradeFactory* SocketContextUpgradeFactorySelector::select(Request& req, Response& res) {
64 SocketContextUpgradeFactory* socketContextUpgradeFactory =
nullptr;
66 std::string upgradeContextNames = req.get(
"upgrade");
68 while (!upgradeContextNames.empty() && socketContextUpgradeFactory ==
nullptr) {
69 std::string upgradeContextName;
70 std::string upgradeContextVersion;
72 std::tie(upgradeContextName, upgradeContextNames) = httputils::str_split(upgradeContextNames,
',');
73 std::tie(upgradeContextName, upgradeContextVersion) = httputils::str_split(upgradeContextName,
'/');
75 httputils::str_trimm(upgradeContextName);
76 httputils::to_lower(upgradeContextName);
78 socketContextUpgradeFactory = select(upgradeContextName);
81 if (socketContextUpgradeFactory !=
nullptr) {
82 socketContextUpgradeFactory->prepare(req, res);
85 return socketContextUpgradeFactory;