本文整理汇总了C++中CUrl::GetUserName方法的典型用法代码示例。如果您正苦于以下问题:C++ CUrl::GetUserName方法的具体用法?C++ CUrl::GetUserName怎么用?C++ CUrl::GetUserName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CUrl
的用法示例。
在下文中一共展示了CUrl::GetUserName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UrlUnescapeInPlace
HRESULT FAsyncDownload::FHttpDownloadTP::ProcessDownload(FAsyncDownData *pData)
{
HRESULT hr = E_FAIL;
FString ReqUrl = pData->m_pUrlInfo->m_DownloadUrl;
UrlUnescapeInPlace(ReqUrl.GetBuffer(), 0);
CUrl url;
url.CrackUrl(ReqUrl);
const tchar* pszUserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)";
FHInternet hIn = NULL;
if (g_AppSettings.m_Proxy.GetLength() > 0)
{
hIn = InternetOpen(pszUserAgent, INTERNET_OPEN_TYPE_PROXY, g_AppSettings.m_Proxy, g_AppSettings.m_ProxyA, 0);
}
else
{
hIn = InternetOpen(pszUserAgent, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
}
if (NULL == hIn)
return E_HTTP_NET_ERROR;
FHInternet hCon = InternetConnect(hIn, url.GetHostName(), url.GetPortNumber(), url.GetUserName(), url.GetPassword(), INTERNET_SERVICE_HTTP, 0, 0);
if (NULL == hCon)
{
_DBGAlert("**FAsyncDownload::FHttpDownloadTP::ProcessDownload: InternetConnect() failed: %d\n", GetLastError());
return E_HTTP_NET_ERROR;
}
ULONG ulRecvTimeout = 15000;
InternetSetOption(hCon, INTERNET_OPTION_RECEIVE_TIMEOUT, &ulRecvTimeout, sizeof(ULONG));
FString StrRes = url.GetUrlPath();
StrRes+= url.GetExtraInfo();
FHInternet hReq = HttpOpenRequest(hCon, "GET", StrRes, NULL, NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE | INTERNET_FLAG_DONT_CACHE, 0);
if (NULL == hReq)
{
_DBGAlert("**FAsyncDownload::FHttpDownloadTP::ProcessDownload: HttpOpenRequest() failed: %d\n", GetLastError());
return E_HTTP_NET_ERROR;
}
size_type FileSize = 0;
if (!(pData->m_pUrlInfo->m_dwDownloadFlags & HTTP_FLAG_NO_RESUME))
FileSize = GetFileSize(pData->m_pUrlInfo->m_DownloadFile);
// See if file already exists on the disk.
if (FileSize > 0)
{
FString StrRange;
StrRange.Format("Range: bytes=%I64d-", FileSize);
HttpAddRequestHeaders(hReq, StrRange, StrRange.GetLength(), HTTP_ADDREQ_FLAG_ADD_IF_NEW);
}
FString StrVersion;
StrVersion.Format("LTV_VERSION: %s", g_AppSettings.m_AppVersion);
HttpAddRequestHeaders(hReq, StrVersion, StrVersion.GetLength(), HTTP_ADDREQ_FLAG_ADD_IF_NEW);
if (!HttpSendRequest(hReq, NULL, 0, NULL, 0))
{
int err = GetLastError();
_DBGAlert("**FAsyncDownload::FHttpDownloadTP::ProcessDownload: HttpSendRequest() failed: %d (0x%x)\n", err, HRESULT_FROM_WIN32(err));
InternetCloseHandle(hCon);
InternetCloseHandle(hIn);
return E_HTTP_NET_ERROR;
}
const DWORD dwBufferSize = 8192;
char pBuffer[dwBufferSize];
FHttpConnection FConn = hReq;
DWORD dwStatusCode = FConn.GetStatusCode();
FString ReqContentType = pData->m_pUrlInfo->m_ContentType;
pData->m_pUrlInfo->m_ContentType = FConn.GetHeader(HTTP_QUERY_CONTENT_TYPE);
pData->m_pUrlInfo->m_dwStatusCode = dwStatusCode;
if (!MatchContentType(ReqContentType, pData->m_pUrlInfo->m_ContentType))
{
_DBGAlert("**FAsyncDownload::FHttpDownloadTP::ProcessDownload: Content type mismatch: %s/%s\n", ReqContentType, pData->m_pUrlInfo->m_ContentType);
return E_NOINTERFACE; //E_NOINTERFACE = content type mismatch
}
if (dwStatusCode == 416 && FileSize > 0)
{
_DBGAlert("FAsyncDownload::FHttpDownloadTP::ProcessDownload: Server status code: %d. Download complete\n", dwStatusCode);
return S_OK;
}
//.........这里部分代码省略.........