80{
81 if (base_url.empty()) {
82 return false;
83 }
84
85 std::string url = base_url;
86 if (boost::istarts_with(url, "https://")) {
88 url = url.substr(8);
89 } else if (boost::istarts_with(url, "http://")) {
90 url = url.substr(7);
91 }
92
93 auto slash = url.find('/');
94 if (slash != std::string::npos) {
95 url = url.substr(0, slash);
96 }
97 if (url.empty()) {
98 return false;
99 }
100
102 endpoint.
port = endpoint.
secure ?
"443" :
"80";
103 if (auto colon = url.rfind(':'); colon != std::string::npos && url.find(']') == std::string::npos) {
104 endpoint.
host = url.substr(0, colon);
105 endpoint.
port = url.substr(colon + 1);
106 }
107
108 endpoint.
target =
"/websocket";
109 return !endpoint.
host.empty() && !endpoint.
port.empty();
110}
std::string target
Definition MoonrakerPrinterAgent.cpp:75
std::string host
Definition MoonrakerPrinterAgent.cpp:73
bool secure
Definition MoonrakerPrinterAgent.cpp:76
std::string port
Definition MoonrakerPrinterAgent.cpp:74