in sdk/src/http/Url.cc [206:238]
void Url::setAuthority(const std::string & authority)
{
if (authority.empty()) {
setUserInfo("");
setHost("");
setPort(INVALID_PORT);
return;
}
std::string userinfo, host, port;
std::string::size_type pos = 0, prevpos = 0;
pos = authority.find('@');
if (pos != authority.npos) {
userinfo = authority.substr(0, pos);
prevpos = pos + 1;
}
else {
pos = 0;
}
pos = authority.find(':', prevpos);
if (pos == authority.npos)
host = authority.substr(prevpos);
else {
host = authority.substr(prevpos, pos - prevpos);
port = authority.substr(pos + 1);
}
setUserInfo(userinfo);
setHost(host);
setPort(!port.empty() ? atoi(port.c_str()): INVALID_PORT);
}