本文整理汇总了C++中CUrl::GetSchemeName方法的典型用法代码示例。如果您正苦于以下问题:C++ CUrl::GetSchemeName方法的具体用法?C++ CUrl::GetSchemeName怎么用?C++ CUrl::GetSchemeName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CUrl
的用法示例。
在下文中一共展示了CUrl::GetSchemeName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QueryIAuthenticate
HRESULT WINAPI MonitorSink::QueryIAuthenticate(void* pv, REFIID riid, LPVOID* ppv, DWORD dw)
{
* ppv = NULL;
if ( pv && InlineIsEqualGUID(riid, IID_IAuthenticate) )
{
MonitorSink * pThis = (MonitorSink *)pv;
if ( pThis->m_pIEHostWindow && ! pThis->m_strURL.IsEmpty() && pThis->m_spTargetProtocol )
{
do
{
CComPtr<IWinInetHttpInfo> spWinInetHttpInfo;
if ( FAILED(pThis->m_spTargetProtocol->QueryInterface(&spWinInetHttpInfo)) ) break;
if ( ! spWinInetHttpInfo ) break;
CHAR szRawHeader[8192]; // IWinInetHttpInfo::QueryInfo() 返回的 Raw Header 不是 Unicode 的
DWORD dwBuffSize = ARRAYSIZE(szRawHeader);
if ( FAILED(spWinInetHttpInfo->QueryInfo(HTTP_QUERY_RAW_HEADERS, szRawHeader, &dwBuffSize, 0, NULL)) ) break;
CString strHeader;
HttpRawHeader2CrLfHeader(szRawHeader, strHeader);
static const WCHAR AUTH_HEAD [] = L"\r\nWWW-Authenticate:";
LPWSTR lpAuth = NULL;
size_t nAuthLen = 0;
if ( ! ExtractFieldValue( strHeader, AUTH_HEAD, & lpAuth, & nAuthLen ) ) break;
if ( ! lpAuth ) break;
CString strAuthScheme;
CString strAuthRealm;
// 可能有以下几种情况:
// WWW-Authenticate: Basic realm="Secure Area"
// WWW-Authenticate: Digest realm="[email protected]", qop="auth,auth-int", nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093", opaque="5ccc069c403ebaf9f0171e9517f40e41"
// WWW-Authenticate: NTLM
// WWW-Authenticate: NTLM <auth token>
LPWSTR pPos = StrStrW(lpAuth, L" ");
if ( pPos )
{
* pPos = L'\0';
strAuthScheme = lpAuth;
do
{
pPos = StrStrIW( pPos + 1, L"realm");
if ( ! pPos ) break;
pPos = StrChrW( pPos + 5, L'=');
if ( ! pPos ) break;
pPos = StrChrW( pPos + 1, L'"');
if ( ! pPos ) break;
LPWSTR lpRealm = pPos + 1;
pPos = StrChrW( lpRealm, L'"');
if ( ! pPos ) break;
* pPos = L'\0';
strAuthRealm = lpRealm;
} while (false);
}
else
{
strAuthScheme = lpAuth;
}
VirtualFree( lpAuth, 0, MEM_RELEASE);
// 由于 NPN_GetAuthenticationInfo 得不到 NTLM 的 domain,没办法做登录,只好不支持了
if (strAuthRealm == _T("NTLM")) return E_NOINTERFACE;
CUrl url;
if ( url.CrackUrl(pThis->m_strURL) )
{
CW2A aScheme(url.GetSchemeName());
CW2A aHost(url.GetHostName());
int aPort = url.GetPortNumber();
char* username = NULL;
char* password = NULL;
uint32_t ulen = 0, plen = 0;
char* szAuthScheme = CStringToUTF8String(strAuthScheme);
char* szAuthRealm = CStringToUTF8String(strAuthRealm);
NPError result = NPN_GetAuthenticationInfo(pThis->m_pIEHostWindow->m_pPlugin->m_pNPInstance, aScheme, aHost, aPort, szAuthScheme, szAuthRealm, &username, &ulen, &password, &plen );
delete[] szAuthScheme;
delete[] szAuthRealm;
if (result != NPERR_NO_ERROR) break;
pThis->m_strUsername = username;
pThis->m_strPassword = password;
NPN_MemFree(username);
NPN_MemFree(password);
}
* ppv = dynamic_cast<IAuthenticate *>(pThis);
//.........这里部分代码省略.........