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

Classes

class  EventSource
 

Typedefs

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

Functions

std::shared_ptr< web::http::client::tools::EventSourceEventSource (const std::string &scheme, const net::in6::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::in6::EventSource ( const std::string &  host,
uint16_t  port,
const std::string &  path 
)
inline

Definition at line 80 of file EventSource.h.

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

Here is the call graph for this function:

◆ EventSource() [2/4]

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

Definition at line 72 of file EventSource.h.

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

Referenced by EventSource(), and EventSource().

Here is the caller graph for this function:

◆ EventSource() [3/4]

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

Definition at line 84 of file EventSource.h.

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

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

Here is the call graph for this function:

◆ EventSource() [4/4]

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

Definition at line 117 of file EventSource.h.

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