示例#1
0
inline
uri::string_type username(const uri &uri_) {
    const uri::string_type user_info = uri_.user_info();
    uri::const_iterator it(boost::begin(user_info)), end(boost::end(user_info));
    for (; it != end; ++it) {
        if (*it == ':') {
            break;
        }
    }
    return uri::string_type(boost::begin(user_info), it);
}
示例#2
0
文件: uri.cpp 项目: PKRoma/cpprestsdk
bool uri::operator == (const uri &other) const
{
    // Each individual URI component must be decoded before performing comparison.
    // TFS # 375865

    if (this->is_empty() && other.is_empty())
    {
        return true;
    }
    else if (this->is_empty() || other.is_empty())
    {
        return false;
    }
    else if (this->scheme() != other.scheme())
    {
        // scheme is canonicalized to lowercase
        return false;
    }
    else if(uri::decode(this->user_info()) != uri::decode(other.user_info()))
    {
        return false;
    }
    else if (uri::decode(this->host()) != uri::decode(other.host()))
    {
        // host is canonicalized to lowercase
        return false;
    }
    else if (this->port() != other.port())
    {
        return false;
    }
    else if (uri::decode(this->path()) != uri::decode(other.path()))
    {
        return false;
    }
    else if (uri::decode(this->query()) != uri::decode(other.query()))
    {
        return false;
    }
    else if (uri::decode(this->fragment()) != uri::decode(other.fragment()))
    {
        return false;
    }

    return true;
}
示例#3
0
inline
std::string authority(const uri &uri_) {
    std::string user_info(uri_.user_info());
	std::string host(uri_.host());
    std::string port(uri_.port());
	std::string authority;
	if (!boost::empty(user_info))
	{
		std::copy(boost::begin(user_info), boost::end(user_info), std::back_inserter(authority));
		authority.push_back('@');
	}
	if (!boost::empty(host))
	{
		std::copy(boost::begin(host), boost::end(host), std::back_inserter(authority));
	}
	if (!boost::empty(port))
	{
		authority.push_back(':');
		std::copy(boost::begin(port), boost::end(port), std::back_inserter(authority));
	}
	return authority;
}
示例#4
0
inline
std::string user_info(const uri &uri_) {
    return uri_.user_info();
}