mirror of
https://github.com/XRPLF/rippled.git
synced 2026-04-29 15:37:57 +00:00
Added utility class for parsing WS urls
This commit is contained in:
@@ -132,4 +132,42 @@ std::string lookup_ws_close_status_string(uint16_t code) {
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool websocketpp::ws_uri::parse(const std::string& uri) {
|
||||
boost::cmatch what;
|
||||
static const boost::regex expression("(ws|wss)://([^/:\\[]+|\\[[0-9:]+\\])(:\\d{1,5})?(/.*)?");
|
||||
|
||||
if (boost::regex_match(uri.c_str(), what, expression)) {
|
||||
if (what[1] == "wss") {
|
||||
secure = true;
|
||||
} else {
|
||||
secure = false;
|
||||
}
|
||||
|
||||
host = what[2];
|
||||
|
||||
if (what[3] == "") {
|
||||
port = (secure ? 443 : 80);
|
||||
} else {
|
||||
unsigned int t_port = atoi(std::string(what[3]).substr(1).c_str());
|
||||
|
||||
if (t_port > 65535) {
|
||||
return false;
|
||||
}
|
||||
|
||||
port = atoi(std::string(what[3]).substr(1).c_str());
|
||||
}
|
||||
|
||||
if (what[4] == "") {
|
||||
resource = "/";
|
||||
} else {
|
||||
resource = what[4];
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user