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

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

?? crobotinternet.cpp

?? Visual C++自動查詢和智能代理程序設計書籍源碼-AnyQuote
?? 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一区二区三区免费野_久草精品视频
国产欧美日韩视频一区二区| 亚洲成国产人片在线观看| 欧美久久免费观看| 91尤物视频在线观看| 成人福利视频在线看| 成人ar影院免费观看视频| 成人中文字幕在线| 成人黄页在线观看| 色欲综合视频天天天| 欧美在线看片a免费观看| 色视频欧美一区二区三区| 一本久久a久久精品亚洲| 色综合久久99| 欧美久久一区二区| 精品电影一区二区| 国产欧美一区二区精品忘忧草| 久久精品综合网| 中文字幕一区二区三区不卡| 亚洲免费资源在线播放| 亚洲国产精品久久久久婷婷884 | 欧美成人一区二区三区| 日韩美女主播在线视频一区二区三区 | 欧美放荡的少妇| 国内成人自拍视频| 久久久久久久精| 26uuu亚洲综合色欧美 | 激情五月婷婷综合| 日韩免费观看高清完整版| 日本欧美一区二区在线观看| 欧美在线综合视频| 亚洲午夜精品网| 欧美日韩一本到| 午夜精品在线看| 欧美一级欧美一级在线播放| 日韩**一区毛片| 欧美一级久久久| 日韩国产欧美在线视频| 欧美一区二区三区四区在线观看| 午夜av电影一区| 日韩午夜三级在线| 国产一区二区三区香蕉| 久久久久久黄色| 成人一区二区三区中文字幕| 中文字幕在线视频一区| 91免费版在线| 日韩精品一区第一页| 日韩你懂的电影在线观看| 精品一区二区三区蜜桃| 久久久www成人免费无遮挡大片| 激情久久久久久久久久久久久久久久| 精品国产91亚洲一区二区三区婷婷| 极品少妇xxxx精品少妇偷拍| 国产清纯美女被跳蛋高潮一区二区久久w| 国产精品99久久久久| 亚洲欧美综合色| 欧美日韩黄视频| 国产精品99精品久久免费| 亚洲欧美在线高清| 欧美精品v日韩精品v韩国精品v| 毛片av一区二区| 国产精品久久久久久一区二区三区 | 成人一区二区三区| 一区二区三区欧美日韩| 91精品国产欧美一区二区| 国产成人亚洲综合a∨婷婷图片 | 久久嫩草精品久久久精品一| 成人aa视频在线观看| 一区二区三区在线高清| 欧美大片一区二区| 99视频精品在线| 久久精品国产在热久久| 国产精品国产自产拍高清av| 欧美另类一区二区三区| 懂色av一区二区三区蜜臀| 成人午夜视频福利| 一区二区在线观看视频| 日韩欧美精品三级| 色婷婷av一区二区三区软件| 美女在线一区二区| 亚洲色图制服诱惑| 亚洲精品在线电影| 欧美亚洲高清一区| 成人免费av在线| 韩国女主播成人在线| 亚洲第四色夜色| 亚洲欧洲日韩一区二区三区| 精品国产乱码久久久久久老虎| 色哟哟一区二区| 成人爽a毛片一区二区免费| 日韩av电影免费观看高清完整版在线观看 | 欧美精品在欧美一区二区少妇| 国产成人精品亚洲午夜麻豆| 日本欧美在线观看| 亚洲永久精品大片| 亚洲美女电影在线| 国产精品乱码一区二区三区软件 | 欧美午夜精品理论片a级按摩| 国产成人精品免费看| 国产在线精品国自产拍免费| 午夜精品久久久久久久99水蜜桃 | 久久精品视频网| 精品免费国产一区二区三区四区| 欧美日韩综合一区| 91丨九色porny丨蝌蚪| av午夜精品一区二区三区| 欧美精品一卡二卡| 欧美欧美欧美欧美| 91福利在线播放| 一本久久综合亚洲鲁鲁五月天| 波多野结衣视频一区| www.欧美.com| 99综合影院在线| 成a人片亚洲日本久久| 国产成人综合亚洲网站| 国产经典欧美精品| 成人免费视频播放| 成+人+亚洲+综合天堂| 成人的网站免费观看| 成人毛片老司机大片| 91首页免费视频| 欧洲另类一二三四区| 欧美日韩国产另类不卡| 欧美一级在线免费| 久久综合九色综合97婷婷| www成人在线观看| 国产精品私人自拍| 亚洲女同ⅹxx女同tv| 亚洲免费av高清| 午夜精品久久久久久久蜜桃app| 三级精品在线观看| 伦理电影国产精品| 国产福利一区在线| 99久久精品国产观看| 欧美日本在线一区| 日韩一区二区三区四区| 久久免费的精品国产v∧| 久久久久久久久久久电影| 日本亚洲最大的色成网站www| 九九视频精品免费| 高清久久久久久| 91福利社在线观看| 日韩免费看网站| 亚洲欧洲成人精品av97| 亚洲第一会所有码转帖| 国内精品国产成人国产三级粉色| av高清不卡在线| 91精品免费观看| 国产三区在线成人av| 亚洲国产乱码最新视频| 国产一区二区在线观看免费| 色婷婷久久综合| 久久伊99综合婷婷久久伊| 亚洲欧美日韩系列| 狠狠色丁香婷婷综合| 91久久精品日日躁夜夜躁欧美| 日韩精品一区二区三区在线播放| 国产精品美女视频| 日韩黄色免费网站| 一本到不卡免费一区二区| 日韩欧美国产一二三区| 亚洲品质自拍视频网站| 精品一区精品二区高清| 91在线观看视频| 精品国产一区二区三区四区四| 亚洲欧美欧美一区二区三区| 国产真实乱对白精彩久久| 欧洲一区在线电影| 国产欧美日韩精品在线| 日韩不卡一区二区| 在线亚洲一区二区| 国产欧美一二三区| 国内精品视频666| 欧美一区二区三区在线看| 日韩美女视频一区二区 | 精品日韩在线一区| 亚洲大型综合色站| 色婷婷久久综合| 国产精品色哟哟网站| 国内精品国产成人国产三级粉色| 欧美色爱综合网| 亚洲猫色日本管| jizzjizzjizz欧美| 中文字幕欧美国产| 国产在线视频一区二区| 日韩欧美自拍偷拍| 亚洲gay无套男同| 在线免费一区三区| 亚洲品质自拍视频| 91美女片黄在线观看| 国产精品成人免费在线| 高清不卡一二三区| 国产女同性恋一区二区| 国产乱人伦精品一区二区在线观看| 91精品国产乱码| 人人狠狠综合久久亚洲| 欧美日韩国产a| 人禽交欧美网站| 精品国产凹凸成av人网站| 久久av老司机精品网站导航| 欧美大片免费久久精品三p|