SNode.C
Loading...
Searching...
No Matches
web::http::client::SocketContextUpgradeFactorySelector Class Reference

#include <SocketContextUpgradeFactorySelector.h>

Inheritance diagram for web::http::client::SocketContextUpgradeFactorySelector:
Collaboration diagram for web::http::client::SocketContextUpgradeFactorySelector:

Public Member Functions

SocketContextUpgradeFactoryselect (const std::string &protocols, Request &req)
 
SocketContextUpgradeFactoryselect (Request &req, Response &res) override
 
- Public Member Functions inherited from web::http::SocketContextUpgradeFactorySelector< web::http::client::SocketContextUpgradeFactory >
bool add (SocketContextUpgradeFactory *socketContextUpgradeFactory)
 
void link (const std::string &socketContextUpgradeName, SocketContextUpgradeFactory *(*linkedPlugin)())
 
void allowDlOpen ()
 
void unload (SocketContextUpgradeFactory *socketContextUpgradeFactory)
 

Static Public Member Functions

static SocketContextUpgradeFactorySelectorinstance ()
 

Private Types

using Super = web::http::SocketContextUpgradeFactorySelector< web::http::client::SocketContextUpgradeFactory >
 

Private Member Functions

SocketContextUpgradeFactoryload (const std::string &socketContextUpgradeName) override
 

Additional Inherited Members

- Public Types inherited from web::http::SocketContextUpgradeFactorySelector< web::http::client::SocketContextUpgradeFactory >
using SocketContextUpgradeFactory = web::http::client::SocketContextUpgradeFactory
 
using Request = typename SocketContextUpgradeFactory::Request
 
using Response = typename SocketContextUpgradeFactory::Response
 
- Protected Member Functions inherited from web::http::SocketContextUpgradeFactorySelector< web::http::client::SocketContextUpgradeFactory >
 SocketContextUpgradeFactorySelector ()=default
 
virtual ~SocketContextUpgradeFactorySelector ()=default
 
SocketContextUpgradeFactoryselect (const std::string &socketContextUpgradeName)
 
bool add (SocketContextUpgradeFactory *socketContextUpgradeFactory, void *handler)
 
SocketContextUpgradeFactoryload (const std::string &socketContextUpgradeName, const std::string &socketContextUpgradeFactoryLibraryFile, const std::string &socketContextUpgradeFactoryFunctionName)
 

Detailed Description

Definition at line 56 of file SocketContextUpgradeFactorySelector.h.

Member Typedef Documentation

◆ Super

Member Function Documentation

◆ instance()

SocketContextUpgradeFactorySelector * web::http::client::SocketContextUpgradeFactorySelector::instance ( )
static

Definition at line 79 of file SocketContextUpgradeFactorySelector.cpp.

79 {
80 static SocketContextUpgradeFactorySelector socketContextUpgradeFactorySelector;
81
82 return &socketContextUpgradeFactorySelector;
83 }

Referenced by web::http::client::SocketContextUpgradeFactory::checkRefCount(), web::http::client::Request::executeUpgrade(), web::http::client::SocketContextUpgradeFactory::link(), and web::http::client::Request::upgrade().

Here is the caller graph for this function:

◆ load()

SocketContextUpgradeFactorySelector::SocketContextUpgradeFactory * web::http::client::SocketContextUpgradeFactorySelector::load ( const std::string &  socketContextUpgradeName)
overrideprivatevirtual

Implements web::http::SocketContextUpgradeFactorySelector< web::http::client::SocketContextUpgradeFactory >.

Definition at line 64 of file SocketContextUpgradeFactorySelector.cpp.

64 {
65 std::string httpUpgradeInstallLibdir = HTTP_UPGRADE_INSTALL_LIBDIR;
66
67#if !defined(NDEBUG)
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);
71 }
72#endif
73
74 return load(socketContextUpgradeName,
75 httpUpgradeInstallLibdir + "/libsnodec-" + socketContextUpgradeName + "-client.so." SOVERSION,
76 socketContextUpgradeName + "ClientSocketContextUpgradeFactory");
77 }
SocketContextUpgradeFactory * load(const std::string &socketContextUpgradeName) override

◆ select() [1/2]

SocketContextUpgradeFactory * web::http::client::SocketContextUpgradeFactorySelector::select ( const std::string &  protocols,
Request req 
)

Definition at line 85 of file SocketContextUpgradeFactorySelector.cpp.

85 {
86 SocketContextUpgradeFactory* socketContextUpgradeFactory = nullptr;
87
88 std::string upgradeContextNames = protocols;
89
90 while (!upgradeContextNames.empty() && socketContextUpgradeFactory == nullptr) {
91 std::string upgradeContextName;
92 std::string upgradeContextVersion;
93
94 std::tie(upgradeContextName, upgradeContextNames) = httputils::str_split(upgradeContextNames, ',');
95 std::tie(upgradeContextName, upgradeContextVersion) = httputils::str_split(upgradeContextName, '/');
96
97 httputils::str_trimm(upgradeContextName);
98 httputils::to_lower(upgradeContextName);
99
100 socketContextUpgradeFactory = select(upgradeContextName);
101 }
102
103 if (socketContextUpgradeFactory != nullptr) {
104 socketContextUpgradeFactory->prepare(req); // Fill in the missing header fields into the request object
105 }
106
107 return socketContextUpgradeFactory;
108 }
SocketContextUpgradeFactory * select(const std::string &protocols, Request &req)
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)

References web::http::client::SocketContextUpgradeFactory::prepare(), web::http::SocketContextUpgradeFactorySelector< SocketContextUpgradeFactoryT >::select(), httputils::str_split(), httputils::str_trimm(), and httputils::to_lower().

Referenced by web::http::client::Request::executeUpgrade().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ select() [2/2]

SocketContextUpgradeFactory * web::http::client::SocketContextUpgradeFactorySelector::select ( Request req,
Response res 
)
overridevirtual

Implements web::http::SocketContextUpgradeFactorySelector< web::http::client::SocketContextUpgradeFactory >.

Definition at line 110 of file SocketContextUpgradeFactorySelector.cpp.

110 {
111 SocketContextUpgradeFactory* socketContextUpgradeFactory = nullptr;
112
113 std::string upgradeContextName = res.get("upgrade");
114
115 if (!upgradeContextName.empty()) {
116 httputils::to_lower(upgradeContextName);
117
118 socketContextUpgradeFactory = select(upgradeContextName);
119
120 if (socketContextUpgradeFactory != nullptr) {
121 socketContextUpgradeFactory->prepare(req, res); // Fill in the missing header fields into the request object
122 }
123 }
124
125 return socketContextUpgradeFactory;
126 }

References web::http::client::Response::get(), web::http::SocketContextUpgradeFactory< RequestT, ResponseT >::prepare(), web::http::SocketContextUpgradeFactorySelector< SocketContextUpgradeFactoryT >::select(), and httputils::to_lower().

Referenced by web::http::client::Request::upgrade().

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following files: