当前位置: 首页>>代码示例>>C++>>正文


C++ CHttpFile::GetLength方法代码示例

本文整理汇总了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();

//.........这里部分代码省略.........
开发者ID:RNCan,项目名称:WeatherBasedSimulationFramework,代码行数:101,代码来源:UIEnvCanRadar.cpp

示例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
}
开发者ID:jimmccurdy,项目名称:ArchiveGit,代码行数:61,代码来源:AcctInfo.cpp


注:本文中的CHttpFile::GetLength方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。