SNode.C
Loading...
Searching...
No Matches
web::http::legacy::in Namespace Reference

Classes

class  EventSource
 

Typedefs

using Client = web::http::client::Client< net::in::stream::legacy::SocketClient >
 
using Server = web::http::server::Server< net::in::stream::legacy::SocketServer >
 

Functions

std::shared_ptr< web::http::client::tools::EventSourceEventSource (const std::string &scheme, const net::in::SocketAddress &socketAddress, const std::string &path)
 
std::shared_ptr< web::http::client::tools::EventSourceEventSource (const std::string &host, uint16_t port, const std::string &path)
 
std::shared_ptr< web::http::client::tools::EventSourceEventSource (const std::string &url)
 
std::shared_ptr< web::http::client::tools::EventSourceEventSource (std::string origin, std::string path)
 

Typedef Documentation

◆ Client

◆ Server

Function Documentation

◆ EventSource() [1/4]

std::shared_ptr< web::http::client::tools::EventSource > web::http::legacy::in::EventSource ( const std::string &  host,
uint16_t  port,
const std::string &  path 
)
inline

Definition at line 82 of file EventSource.h.

References EventSource(), and net::in::SocketAddress::SocketAddress().

Here is the call graph for this function:

◆ EventSource() [2/4]

std::shared_ptr< web::http::client::tools::EventSource > web::http::legacy::in::EventSource ( const std::string &  scheme,
const net::in::SocketAddress socketAddress,
const std::string &  path 
)
inline

Definition at line 74 of file EventSource.h.

74 {
75 std::shared_ptr<class EventSource> eventSource = std::make_shared<class EventSource>();
76 eventSource->init(scheme, socketAddress, path);
77
78 return eventSource;
79 }

References web::http::client::tools::EventSourceT< Client >::init().

Referenced by EventSource(), and EventSource().

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

◆ EventSource() [3/4]

std::shared_ptr< web::http::client::tools::EventSource > web::http::legacy::in::EventSource ( const std::string &  url)
inline

Definition at line 86 of file EventSource.h.

86 {
87 std::shared_ptr<web::http::client::tools::EventSource> eventSource;
88
89 static const std::regex re(
90 R"(^(?:(https?)://)?(?![^/]*@)((?:(?:25[0-5]|2[0-4]\d|1?\d{1,2})\.){3}(?:25[0-5]|2[0-4]\d|1?\d{1,2})|[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?(?:\.[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*)(?::([0-9]{1,5}))?([^?#]*)(\?[^#]*)?(?:#.*)?$)",
91 std::regex::ECMAScript | std::regex::icase);
92
93 std::smatch match;
94 if (std::regex_match(url, match, re)) {
95 // [1] scheme (optional) -> "http" or "https"
96 // [2] host (required) -> hostname or IPv4 token (no [ ], no :)
97 // [3] port (optional) -> digits
98 // [4] path (may be empty)
99 // [5] query (optional)
100
101 const std::string& scheme = match[1].matched ? match[1].str() : "http";
102 const std::string& host = match[2].str();
103 const uint16_t port = match[3].matched ? static_cast<uint16_t>(std::stoi(match[3].str())) : static_cast<uint16_t>(80);
104 const std::string& path = (match[4].matched ? match[4].str() : "/");
105 const std::string& query = (match[5].matched ? match[5].str() : "");
106
107 if (scheme == "http") {
108 eventSource = EventSource(scheme, net::in::SocketAddress(host, port), path);
109 } else {
110 LOG(ERROR) << "Scheme not valid: " << scheme;
111 }
112 } else {
113 LOG(ERROR) << "EventSource url not accepted: " << url;
114 }
115
116 return eventSource;
117 }

References EventSource(), and net::in::SocketAddress::SocketAddress().

Here is the call graph for this function:

◆ EventSource() [4/4]

std::shared_ptr< web::http::client::tools::EventSource > web::http::legacy::in::EventSource ( std::string  origin,
std::string  path 
)
inline

Definition at line 119 of file EventSource.h.

119 {
120 if (!origin.empty() && origin.at(origin.length() - 1) == '/') {
121 origin.pop_back();
122 }
123
124 if (!path.empty() && path.at(0) != '/') {
125 path = "/" + path;
126 }
127
128 return EventSource(!origin.empty() ? origin + path : "");
129 }