本文整理汇总了C++中CHttpFile::GetLength方法的典型用法代码示例。如果您正苦于以下问题:C++ CHttpFile::GetLength方法的具体用法?C++ CHttpFile::GetLength怎么用?C++ CHttpFile::GetLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CHttpFile
的用法示例。
在下文中一共展示了CHttpFile::GetLength方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ExecuteHistorical
ERMsg CUIEnvCanRadar::ExecuteHistorical(CCallback& callback)
{
ERMsg msg;
string workingDir = GetDir(WORKING_DIR);
CreateMultipleDir(workingDir);
CInternetSessionPtr pSession;
CHttpConnectionPtr pConnection;
msg = GetHttpConnection(SERVER_NAME[as<size_t>(TYPE)], pConnection, pSession);
if (!msg)
return msg;
callback.AddMessage(GetString(IDS_UPDATE_DIR));
callback.AddMessage(workingDir, 1);
callback.AddMessage(GetString(IDS_UPDATE_FROM));
callback.AddMessage(SERVER_NAME[as<size_t>(TYPE)], 1);
callback.AddMessage("");
//Get remote station list
StringVector imageList;
if (msg)
msg = GetRadarList(imageList, callback);
if (msg)
msg = CleanRadarList(imageList, callback);
if (!msg)
return msg;
callback.PushTask("Download historical radar images (" + ToString(imageList.size())+ ")", imageList.size());
//callback.SetNbStep(imageList.size());
int nbRun = 0;
int curI = 0;
while (curI<imageList.size() && msg)
{
nbRun++;
CInternetSessionPtr pSession;
CHttpConnectionPtr pConnection;
msg = GetHttpConnection(SERVER_NAME[as<size_t>(TYPE)], pConnection, pSession);
if (msg)
{
TRY
{
for (int i = curI; i<imageList.size() && msg; i++)
{
string filePath = GetOutputFilePath(as<size_t>(TYPE), imageList[i]);
msg += CreateMultipleDir(GetPath(filePath));
//msg += CopyFile(pConnection, imageList[i], filePath, INTERNET_FLAG_TRANSFER_BINARY | WININET_API_FLAG_SYNC);
CString URL(imageList[i].c_str());
CHttpFile* pURLFile = pConnection->OpenRequest(_T("GET"), URL, NULL, 1, NULL, NULL, INTERNET_FLAG_EXISTING_CONNECT | INTERNET_FLAG_TRANSFER_BINARY | WININET_API_FLAG_SYNC | INTERNET_FLAG_NEED_FILE);
//CStdioFile* pURLFile = pSession->OpenURL(UtilWin::Convert(imageList[i]), 0, INTERNET_FLAG_TRANSFER_BINARY | INTERNET_FLAG_EXISTING_CONNECT);
bool bRep = false;
if (pURLFile != NULL)
{
if (pURLFile->SendRequest() != 0)
{
CArray<char> source;
int len = 0;
CArray<char> tmp;
tmp.SetSize(50);
DWORD dwStatusCode = 0;
pURLFile->QueryInfoStatusCode(dwStatusCode);
ULONGLONG length = pURLFile->GetLength();
while (length > 0)
{
pURLFile->Read(tmp.GetData(), 50);
source.Append(tmp);
length = pURLFile->GetLength();
}
pURLFile->QueryInfoStatusCode(dwStatusCode);
pURLFile->Close();
ofStream file;
msg = file.open(filePath, ios::out | ios::binary);
if (msg)
{
if (!source.IsEmpty())
file.write(source.GetData(), (UINT)source.GetSize());
file.close();
//.........这里部分代码省略.........
示例2: ProcessResponse
UINT CAccountInfo::ProcessResponse(CHttpFile& pHttpFile)
{
#ifdef ARTSTORE
return 1;
#else
//Take the HttpFile and parse it.
UINT nFileLength = pHttpFile.GetLength();
CString strBuffer;
CString strSearch;
CString strList;
LPSTR b = strBuffer.GetBuffer(nFileLength);
pHttpFile.Read(b, nFileLength);
strBuffer.ReleaseBuffer();
CBasicRequestInfo::ProcessResponse(strBuffer);
UINT uStatusCode = atoi((LPCTSTR)GetStatusCode());
if(uStatusCode == 0 || uStatusCode == 15) //success or in use
{
CString strSearch;
strSearch = "AccountID=";
CString strTemp = "";
ParseFileForValue(strBuffer, strSearch, strTemp);
m_strServerSuggestedAccountID = strTemp;
if(m_strRequestedAccountID == strTemp){
SetAccountID(strTemp);
CString strResult;
CString strNotify;
strNotify.LoadString(IDS_PGS_ACCOUNTID_NOTIFICATION);
strResult.Format(strNotify, GetAccountID());
AfxMessageBox(strResult, MB_ICONINFORMATION);
//at this point, the server has created our accountID (if new)
CUUEncoder UUEncoder;
GET_PMWAPP()->WriteProfileString(SECTION_ServerAccount,
ENTRY_ServerAccountName,
UUEncoder.EncodeString(GetAccountID()));
GET_PMWAPP()->WriteProfileString(SECTION_ServerAccount,
ENTRY_ServerPassword,
UUEncoder.EncodeString(GetPassword()));
}else{
//try to establish account again
return 100;
}
}
if(!GetStatusCode())
return 1;
else
return 0;
#endif
}