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
 
using Request
 
using 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 34 of file SocketContextUpgradeFactorySelector.h.

Member Typedef Documentation

◆ Super

Member Function Documentation

◆ instance()

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

Definition at line 57 of file SocketContextUpgradeFactorySelector.cpp.

57 {
58 static SocketContextUpgradeFactorySelector socketContextUpgradeFactorySelector;
59
60 return &socketContextUpgradeFactorySelector;
61 }

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

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 42 of file SocketContextUpgradeFactorySelector.cpp.

42 {
43 std::string httpUpgradeInstallLibdir = HTTP_UPGRADE_INSTALL_LIBDIR;
44
45#if !defined(NDEBUG)
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);
49 }
50#endif
51
52 return load(socketContextUpgradeName,
53 httpUpgradeInstallLibdir + "/libsnodec-" + socketContextUpgradeName + "-client.so." SOVERSION,
54 socketContextUpgradeName + "ClientSocketContextUpgradeFactory");
55 }
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 63 of file SocketContextUpgradeFactorySelector.cpp.

63 {
64 SocketContextUpgradeFactory* socketContextUpgradeFactory = nullptr;
65
66 std::string upgradeContextNames = protocols;
67
68 while (!upgradeContextNames.empty() && socketContextUpgradeFactory == nullptr) {
69 std::string upgradeContextName;
70 std::string upgradeContextVersion;
71
72 std::tie(upgradeContextName, upgradeContextNames) = httputils::str_split(upgradeContextNames, ',');
73 std::tie(upgradeContextName, upgradeContextVersion) = httputils::str_split(upgradeContextName, '/');
74
75 httputils::str_trimm(upgradeContextName);
76 httputils::to_lower(upgradeContextName);
77
78 socketContextUpgradeFactory = select(upgradeContextName);
79 }
80
81 if (socketContextUpgradeFactory != nullptr) {
82 socketContextUpgradeFactory->prepare(req); // Fill in the missing header fields into the request object
83 }
84
85 return socketContextUpgradeFactory;
86 }
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)

◆ 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 88 of file SocketContextUpgradeFactorySelector.cpp.

88 {
89 SocketContextUpgradeFactory* socketContextUpgradeFactory = nullptr;
90
91 std::string upgradeContextName = res.get("upgrade");
92
93 if (!upgradeContextName.empty()) {
94 httputils::to_lower(upgradeContextName);
95
96 socketContextUpgradeFactory = select(upgradeContextName);
97
98 if (socketContextUpgradeFactory != nullptr) {
99 socketContextUpgradeFactory->prepare(req, res); // Fill in the missing header fields into the request object
100 }
101 }
102
103 return socketContextUpgradeFactory;
104 }

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