本文整理汇总了C++中Url::GetScheme方法的典型用法代码示例。如果您正苦于以下问题:C++ Url::GetScheme方法的具体用法?C++ Url::GetScheme怎么用?C++ Url::GetScheme使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Url
的用法示例。
在下文中一共展示了Url::GetScheme方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: shouldRedirect
bool RedirectRule::shouldRedirect(const Url & u)
{
std::string url=u.GetString();
if (m_reParse.empty() || url.find(m_reParse.c_str()) != std::string::npos)
{
return false;
}
if(!this->m_isMatchProtocol)
{
//url=url.substr(url.length()-u.GetScheme().length());
if (!u.GetScheme().empty())
{
url=url.substr(u.GetScheme().length()+3);
}
}
if (!m_vwhiteContent.empty() && isMatchContent(m_vwhiteContent,url))
{
return false;
}
if (!m_vblackContent.empty() && !isMatchContent(m_vblackContent,url))
{
return false;
}
bool ret = adbMatch(url.c_str(),m_reRedirect.c_str());
if (ret)
{
m_rule;
}
return ret;
}
示例2: shouldFilter
int FilterRule::shouldFilter(const Url & mainURL,const Url & u,FilterType t)
{
if (!m_stateDomains.empty() && !isMatchState(m_stateDomains))
{
return 0;
}
std::string url=u.GetString();
bool ret;
if(!this->m_isMatchProtocol) {
//url=url.substr(url.length()-u.GetScheme().length());
if (!u.GetScheme().empty())
{
url=url.substr(u.GetScheme().length()+3);
}
}
if(!this->isMatchThirdParty(mainURL,u)) {
return 0;
}
if(!this->isMatchDomains(u) || !this->isMatchDomains(mainURL)) {
return 0;
}
if(!isMatchType(u,t)) {
return 0;
}
ret=adbMatch(url.c_str(),m_reFilter.c_str());
if (ret)
{
if (m_iresponse > 0 && m_iresponse<1000)
{
return m_iresponse;
}
return 1;
}
return 0;
}
示例3: shouldReplace
bool ReplaceRule::shouldReplace(const Url & u)
{
if (!m_stateDomains.empty() && !isMatchState(m_stateDomains))
{
return false;
}
std::string url=u.GetString();
bool ret;
if(!this->m_isMatchProtocol)
{
//url=url.substr(url.length()-u.GetScheme().length());
if (!u.GetScheme().empty())
{
url=url.substr(u.GetScheme().length()+3);
}
}
ret=adbMatch(url.c_str(),m_reReplace.c_str());
return ret;
}
示例4: Parse
Url Url::Parse(const std::string& strRawUrl)
{
// <scheme>://<user>:<password>@<host>:<port>/<path>?<query>#<frag>
// <scheme>:opaque?query#fragment
Url url;
if (strRawUrl.empty())
return url;
do
{
// Firstly, we will split fragment and query string.
std::string strPrefix;
auto spList = base::strings::Split(strRawUrl, "#");
if (spList.size() > 2)
break;
strPrefix = spList[0];
if (spList.size() == 2)
url.m_strFragment = base::Unescape(spList[1]);
spList = base::strings::Split(strPrefix, "?");
if (spList.size() > 2)
break;
strPrefix = spList[0];
if (spList.size() == 2)
url.m_strRawQuery = spList[1];
// Parse scheme.
std::string strRest;
if (!ParseScheme(strPrefix, url.m_strScheme, strRest))
break;
if (url.GetScheme() == "http")
url.SetPort(80);
else if (url.GetScheme() == "https")
url.SetPort(443);
if (strRest.empty())
break;
// <scheme>:opaque
if (!url.m_strScheme.empty() && strRest[0] != '/')
{
url.m_strOpaque = strRest;
break;
} // !if <scheme>:opaque
// Invalid URL.
if (!url.m_strScheme.empty()
&& !base::strings::StartsWith(strRest, "//"))
break;
// Relative path.
if (url.m_strScheme.empty()
&& !base::strings::StartsWith(strRest, "//"))
{
url.m_strPath = base::Unescape(strRest);
break;
}
// Secondly, we will parse the particular case.
// <scheme>:///<path>
if (strRest[2] == '/')
{
auto pos1 = strRest.find_first_not_of('/');
if (std::string::npos == pos1)
break;
url.m_strPath = base::Unescape(strRest.substr(pos1 - 1));
break;
} // !if <scheme>:///<path>
// <scheme>://<user>:<password>@<host>:<port>/<path>
auto pos1 = strRest.find_first_not_of('/');
if (std::string::npos == pos1)
break;
auto pos2 = strRest.find_first_of("/", pos1);
std::string strAuthority;
if (std::string::npos == pos2)
strAuthority = strRest.substr(pos1);
else
strAuthority = strRest.substr(pos1, pos2 - pos1);
if (!ParseAuthority(strAuthority, url.m_strUserName, url.m_strPassword,
url.m_strHost, url.m_iPort))
{
url.m_strUserName = "";
url.m_strPassword = "";
url.m_strHost = "";
url.m_iPort = 0;
break;
}
if (pos2 == std::string::npos)
{
url.m_strPath = "/";
break;
}
url.m_strPath = base::Unescape(strRest.substr(pos2));
} while (0);
return url;
}