亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? crobotinternet.cpp

?? beereader source code
?? CPP
?? 第 1 頁 / 共 4 頁
字號:
	sErrMsg = "";
	DWORD dwHttpStatus;
	nResult = CROBOT_ERR_SUCCESS;
	CString sMsg;

	try 
	{
		pSession = NULL;
		pHttpFile = NULL;
		pLocalFile = NULL;
		sHeader = CreateStandardHeader();
		nRead = 0;
		pBuffer = new char[1024];
		sResult = "";
		sWorkingUrl = sURL;

		/* Trim URL and add http:// if it contains no 
		   protocol identifier */

		sWorkingUrl.TrimLeft();
		sWorkingUrl.TrimRight();
		if (sWorkingUrl.Find(":") == -1) 
		{
			if (sWorkingUrl.Left(1) == "/")
				sWorkingUrl = "http:" + sWorkingUrl;
			else
				sWorkingUrl = "http://" + sWorkingUrl;
		} // End if

		// Check for invalid parameters
		if (!(sURL.IsEmpty()) && !(sOutputFilespec.IsEmpty()))
		{
			// URL is not empty and output file spec is not empty
			/* Check the URL - must be valid and 
			   of the 'http:' service type */
			DWORD dwServiceType;
			CString sServer, sObject;
			unsigned short nPort;
			if (AfxParseURL(sWorkingUrl,
							dwServiceType,
							sServer,
							sObject,
							nPort)) 
			{
				if (dwServiceType == AFX_INET_SERVICE_HTTP)
				{
					pSession = new CInternetSession(
											m_sUserAgent,
											++m_nContext,
											INTERNET_OPEN_TYPE_PRECONFIG);

					pHttpFile = (CHttpFile*) 
						pSession->OpenURL(
									sWorkingUrl,
									1,
									INTERNET_FLAG_RELOAD
									    | INTERNET_FLAG_DONT_CACHE
										| INTERNET_FLAG_TRANSFER_BINARY
										| INTERNET_FLAG_EXISTING_CONNECT,
								    sHeader,
									-1L);
					if (pHttpFile) /* OpenURL worked */
					{
						// Check the http return code
						if (!pHttpFile->QueryInfoStatusCode(dwHttpStatus))
							dwHttpStatus = 200;

						if (dwHttpStatus >= 400)
						{
							switch(dwHttpStatus)
							{
							case 404:
								nResult = CROBOT_ERR_NOT_FOUND;
								break;
							case 403:
							case 407:
								nResult = CROBOT_ERR_NOT_AUTHORIZED;
								break;
							default:
								nResult = CROBOT_ERR_CONNECTION_FAILED;
								break;
							} // End switch
						} // End if dwHttpStatus
						else /* No error - read response data */
						{
							nResult = CROBOT_ERR_SUCCESS;
							// Open local file for output
							pLocalFile = new CFile;
							pLocalFile->Open(sOutputFilespec,
											 CFile::modeWrite 
											     | CFile::modeCreate);
							// Read the data
							do 
							{
								nRead = pHttpFile->Read(pBuffer, 1023);
								if (nRead != 0)
								{
									pBuffer[nRead] = 0;
									pLocalFile->Write(pBuffer, nRead);
									if (sResult == "") sResult = pBuffer;
								} // End if
							} while (nRead != 0);
						} // End else
						// Check for error embedded in return page
					} // End if pHttpFile
					else /* OpenURL failed */
					{
						nResult = CROBOT_ERR_CONNECTION_FAILED;
					} // End else
				} // End if
				else
					// Wrong service
					nResult = CROBOT_ERR_INVALID_URL;
			} // End if
			else
				// Invalid URL
				nResult = CROBOT_ERR_INVALID_URL;
		} // End if
		else
			// Empty URL or empty filespec
			nResult = CROBOT_ERR_INVALID_PARAMETER;
	} // End try

	catch(CFileException* e) 
	{
		int nErr = e->m_cause;
		e->Delete();
		delete pLocalFile;
		pLocalFile = NULL;
		// File exception occurred
		nResult = CROBOT_ERR_FILE + nErr;
	} // End catch

	catch (CInternetException* e)
	{
		e->Delete();
		
		// Internet exception occurred
		nResult = CROBOT_ERR_CONNECTION_FAILED;
	} // End catch

	catch (...) 
	{
		// Exception occurred
		nResult = CROBOT_ERR_CONNECTION_FAILED;
	} // End catch

// Clean up and exit function

	if (pBuffer != NULL) 
	{
		delete pBuffer;
		pBuffer = NULL;
	} // End if

	if (pHttpFile != NULL) 
	{
		pHttpFile->Close();
		delete pHttpFile;
	} // End if

	if (pLocalFile != NULL) 
	{
		pLocalFile->Close();
		delete pLocalFile;
	} // End if

	if (pSession != NULL) 
	{
		pSession->Close();
		delete pSession;
	} // End if

	sErrMsg = ErrorMessage(nResult);
	if (nResult == CROBOT_ERR_SUCCESS)
		return true;
	else
		return false;
}


// --------------------------------------------------------------
// **************** public
// *              *
// *  httpHeader  *
// *              *
// ****************
// Function: Retrieves a server header for a URL and returns it
//           in CString form.
//			 See also: Similar function httpHeaderFields.
//
// Inputs:	sURL              - The target URL
//								 (example: "www.mysite.com")
//
// Outputs:	<function_result> - True if header was successfully 
//                               retrieved, false otherwise.
//			sResponse         - The header returned by the server
//			nResult           - completion code; 0 = success,
//								 n = error (defined in CRobot.h)
//			sErrMsg           - the error message, if nResult != 0

BOOL CRobotInternet::httpHeader(const CString& sUrl,
								CString& sResponse,
								int& nResult,
								CString& sErrMsg) 
{
	CInternetSession* pSession;
	CHttpConnection* pConnection;
	CHttpFile* pHttpFile;
	CString sHeader;
	int nRead;
	LPSTR pBuffer;
	CString sResult;
	CString sWorkingUrl;
	CString sMsg;
	sErrMsg = "";
	nResult = CROBOT_ERR_CONNECTION_FAILED;

	try 
	{
		pSession = NULL;
		pConnection = NULL;
		pHttpFile = NULL;
		pHttpFile = NULL;
		sHeader = CreateStandardHeader();
		nRead = 0;
		pBuffer = new char[1024];
		sResult = "";
		sWorkingUrl = sUrl;

		/* Trim URL and add http:// if it contains no 
		   protocol identifier */
		
		sWorkingUrl.TrimLeft();
		sWorkingUrl.TrimRight();
		if (sWorkingUrl.Find(":") == -1) 
		{
			if (sWorkingUrl.Left(1) == "/")
				sWorkingUrl = "http:" + sWorkingUrl;
			else
				sWorkingUrl = "http://" + sWorkingUrl;
		} // End if

		// Check for invalid parameters
		if (!sUrl.IsEmpty()) 
		{
			// URL is not empty
			/* Check the URL - must be valid and of the 'http:'
			   service type */
			DWORD dwServiceType;
			CString sServer, sObject;
			unsigned short nPort;
			if (AfxParseURL(sWorkingUrl,
							dwServiceType,
							sServer,
							sObject,
							nPort))
			{
				//URL is valid. Now check service type.
				if (dwServiceType == AFX_INET_SERVICE_HTTP) 
				{
					//Service type is valid. Make connection.
					pSession = new CInternetSession(
										m_sUserAgent,
										1,
										INTERNET_OPEN_TYPE_PRECONFIG);
					pConnection = pSession->GetHttpConnection(sServer,
															  nPort,
															  NULL,
															  NULL);
					pHttpFile = pConnection->OpenRequest(
									CHttpConnection::HTTP_VERB_HEAD,
									sObject,
									NULL,
									1,
									NULL,
									NULL,
									INTERNET_FLAG_EXISTING_CONNECT
										| INTERNET_FLAG_RELOAD
										| INTERNET_FLAG_DONT_CACHE);
					if (pHttpFile->SendRequest()) /* SendRequest worked */
					{
						DWORD dwHttpStatus;
						// Check the http return code
						if(!pHttpFile->QueryInfoStatusCode(dwHttpStatus))
							dwHttpStatus = 400;

						if (dwHttpStatus >= 400)
						{
							switch(dwHttpStatus)
							{
							case 404:
								nResult = CROBOT_ERR_NOT_FOUND;
								break;
							case 403:
							case 407:
								nResult = CROBOT_ERR_NOT_AUTHORIZED;
								break;
							default:
								nResult = CROBOT_ERR_CONNECTION_FAILED;
								break;
							} // End switch
							unsigned long nFlag = 1; // HTTP_QUERY_CUSTOM;
							unsigned long nChars = 1023;
							DWORD nFlag2 = HTTP_QUERY_RAW_HEADERS_CRLF;
							pHttpFile->QueryInfo(nFlag2, sResult, NULL);
							sResponse = sResult;
						} // End if dwHttpStatus
						else /* No error - read response data */
						{
							nResult = CROBOT_ERR_SUCCESS;
							// Read the data
							do 
							{
								nRead = pHttpFile->Read(pBuffer, 1023);
								if (nRead != 0)
								{
									pBuffer[nRead] = 0;
									sResult += pBuffer;
								} // End if
							} while (nRead != 0);
							sResponse = sResult;
						} // End else
					} // End if pHttpFile
					else /* SendRequest failed */
						nResult = CROBOT_ERR_CONNECTION_FAILED;
					
				} // End if
				else
					// Wrong service
					nResult = CROBOT_ERR_INVALID_URL;
			} // End if
			else
				// Invalid URL
				nResult = CROBOT_ERR_INVALID_URL;
		} // End if
		else
			// Empty URL
			nResult =  CROBOT_ERR_INVALID_PARAMETER;
	} // End try

	catch (CInternetException* e) 
	{
		e->Delete();
		sResponse = sResult;

		// Internet exception occurred
		nResult =  CROBOT_ERR_CONNECTION_FAILED;
	} // End catch
	catch (...) 
	{
		sResponse = sResult;
		
		// Exception occurred
		nResult = CROBOT_ERR_CONNECTION_FAILED;
	} // End catch

// Clean up and exit function

	if (pBuffer != NULL) 
	{
		delete pBuffer;
		pBuffer = NULL;
	} // End if

	if (pHttpFile != NULL) 
	{
		pHttpFile->Close();
		delete pHttpFile; 
	} // End if

	if (pConnection != NULL) 
	{
		pConnection->Close();
		delete pConnection; 
	} // End if

	if (pSession != NULL) 
	{
		pSession->Close();
		delete pSession; 
	} // End if

	sErrMsg = ErrorMessage(nResult);
	if (nResult == CROBOT_ERR_SUCCESS)
		return true;
	else
		return false;
}


// --------------------------------------------------------------
// ********************** public
// *                    *
// *  httpHeaderFields  *
// *                    *
// **********************
// Function: Retrieves a server header for a URL and returns it in
//           CString form. Like httpHeader, but also parses header
//           into individual field names and values.
//
// Inputs:   sURL              - The target URL
//								 (example: "www.mysite.com")
//
// Outputs:	 <function_result> - True if header was successfully 
//								 retrieved, false otherwise
//			 sResponse         - The header returned by the server
//			 nResult           - Completion code. 0 = success,
//								 n = error (defined in CRobot.h)
//			 sErrMsg           - The error message, if nResult != 0
//			 m_sHeader		   - Copy of the header string
//			 m_nHeaderFields   - Set to number of header fields
//			 m_sHeadName[]     - Contains individual header field names
//			 m_sHeadValue[]    - Contains individual header field values

BOOL CRobotInternet::httpHeaderFields(const CString& sUrl,
									  CString& sResponse,
									  int& nResult,
									  CString& sErrMsg) 
{
	CInternetSession* pSession;
	CHttpConnection* pConnection;
	CHttpFile* pHttpFile;
	CString sHeader;
	int nRead;
	LPSTR pBuffer;
	CString sResult;
	CString sWorkingUrl;
	CString sMsg;
	CString sHTML, sTemp;
	int nPos;
	sErrMsg = "";
	nResult = CROBOT_ERR_SUCCESS;
	m_nHeaderFields = 0;

	try 
	{
		pSession = NULL;
		pConnection = NULL;
		pHttpFile = NULL;
		sHeader = CreateStandardHeader();
		nRead = 0;
		pBuffer = new char[1024];
		sResult = "";
		sWorkingUrl = sUrl;

		/* Trim URL and add http:// if it contains no 
		   protocol identifier */
		
		sWorkingUrl.TrimLeft();
		sWorkingUrl.TrimRight();
		if (sWorkingUrl.Find(":") == -1) 
		{
			if (sWorkingUrl.Left(1) == "/")
				sWorkingUrl = "http:" + sWorkingUrl;
			else
				sWorkingUrl = "http://" + sWorkingUrl;
		} // End if

		// Check for invalid parameters
		if (!sUrl.IsEmpty()) 
		{
			// URL is not empty
			/* Check the URL - must be valid and of the 'http:'
			   service type */
			DWORD dwServiceType;
			CString sServer, sObject;
			unsigned short nPort;
			if (AfxParseURL(sWorkingUrl,
							dwServiceType,
							sServer,
							sObject,
							nPort)) 
			{
				// URL is valid. Now check service type.
				if (dwServiceType == AFX_INET_SERVICE_HTTP) 
				{
					//Service type is valid. Make connection.
					pSession = new CInternetSession(
										m_sUserAgent,
										1,
										INTERNET_OPEN_TYPE_PRECONFIG);
					pConnection = pSession->GetHttpConnection(sServer,
															  nPort,
															  NULL,
															  NULL);

					pHttpFile = pConnection->OpenRequest(
									CHttpConnection::HTTP_VERB_HEAD,
									sObject,
									NULL,
									1,
									NULL,
									NULL,
									INTERNET_FLAG_EXISTING_CONNECT
										| INTERNET_FLAG_RELOAD
										| INTERNET_FLAG_DONT_CACHE);
					pHttpFile->SendRequest();
					
					unsigned long nFlag = 1;	// HTTP_QUERY_CUSTOM;
					unsigned long nChars = 1023;
					DWORD nFlag2 = HTTP_QUERY_RAW_HEADERS_CRLF;
					pHttpFile->QueryInfo(nFlag2, sResult, NULL);
					sResponse = sResult;
					nResult =  CROBOT_ERR_SUCCESS;
				} // End if
				else
					// Wrong service
					nResult = CROBOT_ERR_INVALID_URL;
			} // End if
			else
				// Invalid URL
				nResult = CROBOT_ERR_INVALID_URL;
		} // End if
		else
			// Empty URL
			nResult =  CROBOT_ERR_INVALID_PARAMETER;
	} // End try

	catch (CInternetException* e) 
	{
		e->Delete();
		sResponse = sResult;
		
		// Internet exception occurred
		nResult =  CROBOT_ERR_CONNECTION_FAILED;
	} // End catch
	catch (...) 
	{
		sResponse = sResult;
		
		// Exception occurred
		nResult = CROBOT_ERR_CONNECTION_FAILED;
	} // End catch

// Clean up and exit function

	if (pBuffer != NULL) 
	{
		delete pBuffer;
		pBuffer = NULL;
	} // End if

	if (pHttpFile != NULL)
	{
		pHttpFile->Close();
		delete pHttpFile; 
	} // End if

	if (pConnection != NULL)
	{
		pConnection->Close();
		delete pConnection; 
	} // End if

	if (pSession != NULL)
	{
		pSession->Close();
		delete pSession; 
	} // End if

	sErrMsg = ErrorMessage(nResult);
	if (nResult == CROBOT_ERR_SUCCESS)
	{
		// Parse header into individual fields
		m_sHeader = sResponse;
		m_nHeaderFields = 0;
		sHTML = sResponse;
		if (sHTML.Right(1) != "\n")
			sHTML += "\n";
		nPos = sHTML.Find("\n");
		while (nPos != -1)
		{
			sTemp = sHTML.Left(nPos);
			sHTML = sHTML.Mid(nPos + 1);
			nPos = sTemp.Find(":");
			if (nPos != -1)
			{
				m_sHeadName[m_nHeaderFields] = sTemp.Left(nPos);
				m_sHeadValue[m_nHeaderFields] = sTemp.Mid(nPos+1);
				m_sHeadValue[m_nHeaderFields].TrimLeft();
				m_sHeadValue[m_nHeaderFields].TrimRight();
				m_nHeaderFields++;
			} // End if
			nPos = sHTML.Find("\n");
		} // End while
		return true;
	} // End if
	else
		return false;
}


// --------------------------------------------------------------
// ************************ public
// *                      *
// *  httpGetHeaderField  *

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美性猛交xxxx黑人交| 欧美国产精品劲爆| 国产网站一区二区三区| 一区二区三区久久| 国产黄色精品网站| 日韩免费观看高清完整版在线观看| 国产精品久久久久三级| 久久se这里有精品| 欧美美女一区二区在线观看| 国产精品美女一区二区| 国产一区二区三区免费在线观看| 欧美一a一片一级一片| 国产精品免费aⅴ片在线观看| 美女www一区二区| 欧美日韩国产高清一区二区 | 国产精品一区二区三区网站| 欧洲另类一二三四区| 国产精品国产三级国产有无不卡| 美女任你摸久久| 91精品国产麻豆国产自产在线 | 久久九九久久九九| 免费成人在线播放| 欧美电影影音先锋| 亚洲国产日韩在线一区模特| 97超碰欧美中文字幕| 国产欧美一区二区精品性色| 精品一区二区免费看| 精品日韩一区二区| 黑人巨大精品欧美黑白配亚洲| 欧美精选一区二区| 天堂资源在线中文精品| 色婷婷久久久亚洲一区二区三区| 成人免费一区二区三区视频| 精品久久国产字幕高潮| 久久精品国产77777蜜臀| 91精品国产高清一区二区三区| 天天影视网天天综合色在线播放| 一道本成人在线| 一二三区精品视频| 色哟哟精品一区| 亚洲影院久久精品| 91麻豆精品国产91久久久久久| 美女视频黄 久久| 久久久久久免费| 丰满少妇久久久久久久| 自拍av一区二区三区| 91精品国产91热久久久做人人| 欧美aaaaaa午夜精品| 久久久久久久久岛国免费| 国产成a人亚洲| 亚洲天堂2016| 在线电影国产精品| 国产精品一区二区久激情瑜伽| 国产日韩欧美电影| 日本大香伊一区二区三区| 午夜a成v人精品| 国产午夜亚洲精品不卡| 色欧美片视频在线观看| 日韩中文字幕91| 久久久精品人体av艺术| 一本大道久久a久久综合婷婷| 午夜久久久久久久久| 久久无码av三级| 在线观看日韩电影| 蜜桃视频免费观看一区| 国产精品国产a| 欧美一二三区在线| jvid福利写真一区二区三区| 亚洲成人777| 国产日韩一级二级三级| 欧美自拍偷拍午夜视频| 激情丁香综合五月| 一区二区三区.www| 国产精品家庭影院| 91精品国产全国免费观看| 国产999精品久久久久久| 亚洲成av人在线观看| 国产人伦精品一区二区| 欧美精品第一页| 成人avav影音| 日韩av电影一区| 亚洲欧美日韩久久| 欧美一级高清大全免费观看| 91看片淫黄大片一级在线观看| 免费观看一级欧美片| 夜夜嗨av一区二区三区| 国产欧美日本一区二区三区| 欧美裸体一区二区三区| 91日韩精品一区| 成人免费的视频| 国产一区二三区好的| 视频一区欧美日韩| 亚洲一级不卡视频| 亚洲日本va午夜在线影院| 久久新电视剧免费观看| 宅男在线国产精品| 欧美日韩二区三区| 欧洲生活片亚洲生活在线观看| 成人蜜臀av电影| 国产河南妇女毛片精品久久久| 日本成人在线视频网站| 天天射综合影视| 视频一区在线视频| 婷婷国产v国产偷v亚洲高清| 亚洲女女做受ⅹxx高潮| 最新国产精品久久精品| 中文字幕 久热精品 视频在线| 欧美va日韩va| 精品粉嫩超白一线天av| 日韩欧美123| 日韩视频一区在线观看| 日韩欧美成人一区二区| 日韩欧美一区二区在线视频| 91精品国产欧美一区二区18| 欧美久久高跟鞋激| 欧美一区二区三区精品| 欧美一区二区三区视频在线| 91精品国产乱码| 日韩美女天天操| 亚洲国产精品久久人人爱| 亚洲男同1069视频| 亚洲一区二区在线免费看| 亚洲一区二区在线免费看| 日韩国产精品久久久久久亚洲| 三级一区在线视频先锋| 美日韩一区二区| 久久成人免费网| 国产99久久久久| 色老汉一区二区三区| 欧美日韩一区二区三区四区 | 成人三级伦理片| 91年精品国产| 欧美日韩dvd在线观看| 日韩视频123| 国产女同性恋一区二区| 亚洲视频在线观看一区| 日韩国产高清在线| 国产乱码精品一区二区三区忘忧草 | 欧美一级高清片在线观看| 精品盗摄一区二区三区| 欧美国产亚洲另类动漫| 亚洲精品美腿丝袜| 视频一区二区三区在线| 国产精品一区二区三区四区| 91麻豆精东视频| 91麻豆精品国产自产在线观看一区| 亚洲精品在线免费播放| 亚洲人亚洲人成电影网站色| 天天综合色天天综合色h| 国产高清在线观看免费不卡| 欧美在线小视频| 久久久三级国产网站| 亚洲午夜视频在线观看| 国产电影一区在线| 欧美日韩美少妇| 国产欧美精品国产国产专区| 午夜精品一区二区三区三上悠亚| 国产麻豆精品久久一二三| 在线一区二区三区四区五区| 日韩一区二区电影| 亚洲激情在线激情| 国产精品18久久久久久久久 | 午夜不卡在线视频| 成人av资源网站| 精品国产乱码久久久久久久久 | 欧美日韩另类一区| 欧美国产日韩一二三区| 天天爽夜夜爽夜夜爽精品视频| 粉嫩av一区二区三区| 欧美一级片在线观看| 一级女性全黄久久生活片免费| 国产v综合v亚洲欧| 精品三级在线观看| 日日夜夜精品视频免费| 色综合色狠狠天天综合色| 国产农村妇女毛片精品久久麻豆| 亚洲一区二区三区自拍| 99re成人在线| 久久久九九九九| 精品写真视频在线观看| 正在播放亚洲一区| 亚洲成人资源在线| 在线亚洲人成电影网站色www| 国产精品免费视频一区| 国产麻豆精品在线| 26uuu亚洲综合色| 麻豆专区一区二区三区四区五区| 欧美私人免费视频| 亚洲一二三四区| 在线这里只有精品| 亚洲精品视频自拍| 在线视频国内一区二区| 麻豆精品国产传媒mv男同| 欧美另类变人与禽xxxxx| 亚洲成人免费视频| 欧美亚洲免费在线一区| 亚洲成人精品一区| 538在线一区二区精品国产| 五月综合激情网| 日韩欧美一二区|