本文整理汇总了C++中COMPtr::HTTPMethod方法的典型用法代码示例。如果您正苦于以下问题:C++ COMPtr::HTTPMethod方法的具体用法?C++ COMPtr::HTTPMethod怎么用?C++ COMPtr::HTTPMethod使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类COMPtr
的用法示例。
在下文中一共展示了COMPtr::HTTPMethod方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: didNavigateWithNavigationData
// IWebHistoryDelegate
HRESULT HistoryDelegate::didNavigateWithNavigationData(IWebView* webView, IWebNavigationData* navigationData, IWebFrame* webFrame)
{
if (!gLayoutTestController->dumpHistoryDelegateCallbacks())
return S_OK;
BSTR urlBSTR;
if (FAILED(navigationData->url(&urlBSTR)))
return E_FAIL;
wstring url;
if (urlBSTR)
url = urlSuitableForTestResult(wstringFromBSTR(urlBSTR));
SysFreeString(urlBSTR);
BSTR titleBSTR;
if (FAILED(navigationData->title(&titleBSTR)))
return E_FAIL;
wstring title;
if (titleBSTR)
title = wstringFromBSTR(titleBSTR);
SysFreeString(titleBSTR);
COMPtr<IWebURLRequest> request;
if (FAILED(navigationData->originalRequest(&request)))
return E_FAIL;
BSTR httpMethodBSTR;
if (FAILED(request->HTTPMethod(&httpMethodBSTR)))
return E_FAIL;
wstring httpMethod;
if (httpMethodBSTR)
httpMethod = wstringFromBSTR(httpMethodBSTR);
SysFreeString(httpMethodBSTR);
COMPtr<IWebURLResponse> response;
if (FAILED(navigationData->response(&response)))
return E_FAIL;
COMPtr<IWebHTTPURLResponse> httpResponse;
if (FAILED(response->QueryInterface(&httpResponse)))
return E_FAIL;
int statusCode = 0;
if (FAILED(httpResponse->statusCode(&statusCode)))
return E_FAIL;
BOOL hasSubstituteData;
if (FAILED(navigationData->hasSubstituteData(&hasSubstituteData)))
return E_FAIL;
BSTR clientRedirectSourceBSTR;
if (FAILED(navigationData->clientRedirectSource(&clientRedirectSourceBSTR)))
return E_FAIL;
bool hasClientRedirect = clientRedirectSourceBSTR && SysStringLen(clientRedirectSourceBSTR);
wstring redirectSource;
if (clientRedirectSourceBSTR)
redirectSource = urlSuitableForTestResult(wstringFromBSTR(clientRedirectSourceBSTR));
SysFreeString(clientRedirectSourceBSTR);
bool wasFailure = hasSubstituteData || (httpResponse && statusCode >= 400);
printf("WebView navigated to url \"%S\" with title \"%S\" with HTTP equivalent method \"%S\". The navigation was %s and was %s%S.\n",
url.c_str(),
title.c_str(),
httpMethod.c_str(),
wasFailure ? "a failure" : "successful",
hasClientRedirect ? "a client redirect from " : "not a client redirect",
redirectSource.c_str());
return S_OK;
}
示例2: didNavigateWithNavigationData
// IWebHistoryDelegate
HRESULT HistoryDelegate::didNavigateWithNavigationData(_In_opt_ IWebView* webView, _In_opt_ IWebNavigationData* navigationData, _In_opt_ IWebFrame* webFrame)
{
if (!gTestRunner->dumpHistoryDelegateCallbacks())
return S_OK;
_bstr_t urlBSTR;
if (FAILED(navigationData->url(&urlBSTR.GetBSTR())))
return E_FAIL;
wstring url;
if (urlBSTR.length())
url = urlSuitableForTestResult(wstringFromBSTR(urlBSTR));
_bstr_t titleBSTR;
if (FAILED(navigationData->title(&titleBSTR.GetBSTR())))
return E_FAIL;
if (!static_cast<char*>(titleBSTR))
titleBSTR = L"";
COMPtr<IWebURLRequest> request;
if (FAILED(navigationData->originalRequest(&request)))
return E_FAIL;
_bstr_t httpMethodBSTR;
if (FAILED(request->HTTPMethod(&httpMethodBSTR.GetBSTR())))
return E_FAIL;
if (!static_cast<char*>(httpMethodBSTR))
httpMethodBSTR = L"";
COMPtr<IWebURLResponse> response;
if (FAILED(navigationData->response(&response)))
return E_FAIL;
COMPtr<IWebHTTPURLResponse> httpResponse;
if (FAILED(response->QueryInterface(&httpResponse)))
return E_FAIL;
int statusCode = 0;
if (FAILED(httpResponse->statusCode(&statusCode)))
return E_FAIL;
BOOL hasSubstituteData;
if (FAILED(navigationData->hasSubstituteData(&hasSubstituteData)))
return E_FAIL;
_bstr_t clientRedirectSourceBSTR;
if (FAILED(navigationData->clientRedirectSource(&clientRedirectSourceBSTR.GetBSTR())))
return E_FAIL;
if (!static_cast<char*>(clientRedirectSourceBSTR))
clientRedirectSourceBSTR = L"";
bool hasClientRedirect = clientRedirectSourceBSTR.length();
wstring redirectSource;
if (clientRedirectSourceBSTR.length())
redirectSource = urlSuitableForTestResult(wstringFromBSTR(clientRedirectSourceBSTR));
bool wasFailure = hasSubstituteData || (httpResponse && statusCode >= 400);
printf("WebView navigated to url \"%S\" with title \"%s\" with HTTP equivalent method \"%s\". The navigation was %s and was %s%S.\n",
url.c_str(),
static_cast<char*>(titleBSTR),
static_cast<char*>(httpMethodBSTR),
wasFailure ? "a failure" : "successful",
hasClientRedirect ? "a client redirect from " : "not a client redirect",
redirectSource.c_str());
return S_OK;
}