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

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

?? crobotinternet.cpp

?? beereader source code
?? CPP
?? 第 1 頁 / 共 4 頁
字號:
// *                      *
// ************************
// Function: Returns the value for the specified header field.
//			 Call httpHeaderFields before calling this function.
//
// Inputs:	 sFieldName		  - The header field name desired 
//								 (example: "Last-modified").
//			 m_sHeader		  - Set from previous call to 
//								 httpHeaderFields
//			 m_nHeaderFields  - Set from previous call to 
//                               httpHeaderFields
//			 m_sHeaderName[]  - Set from previous call to
//								 httpHeaderFields
//			 m_sHeaderValue[] - Set from previous call to
//								 httpHeaderFields
//
// Outputs:	<function_result> - True if header field was found
//			sValue            - Value for the field

BOOL CRobotInternet::httpGetHeaderField(const CString& sName,
										CString& sValue)
{
	CString sTemp1;
	CString sTemp2;
	sValue = "";
	sTemp1 = sName;
	sTemp1.MakeLower();
	if (sTemp1.Right(1) == ":")
		sTemp1 = sTemp1.Left(sTemp1.GetLength() - 1);
	
	for (int n = 0; n < m_nHeaderFields; n++)
	{
		sTemp2 = m_sHeadName[n];
		sTemp2.MakeLower();
		if (sTemp1 == sTemp2)
		{
			sValue = m_sHeadValue[n];
			n = m_nHeaderFields;
			return true;
			} // End if
	} // End for
	return false;
}


// --------------------------------------------------------------
// ************** public
// *            *
// *  httpPost  *
// *            *
// **************
// Function: Submits a URL and form data/parameters using the POST
//           method. Retrieves a response returns it in CString form.
//
// Inputs:	sURL              - The URL to access
//								 (example: "www.mysite.com")
//			sData			  - The parameters (or "form data")
//								 to submit
//
// Outputs:	<function_result> - True if data was successfully
//								 retrieved, false otherwise
//			sResponse         - The HTML retrieved
//			nResult           - Completion code. 0 = success,
//								 n = error (defined in CRobot.h)
//			sErrMsg           - The error message, if nResult != 0

BOOL CRobotInternet::httpPost(const CString& sUrl,
							  const CString& sData,
							  CString& sResponse,
							  int& nResult, CString& sErrMsg)
{
	CInternetSession* pSession;
	CHttpConnection* pConnection;
	CHttpFile* pHttpFile;
	int nRead;
	LPSTR pBuffer = NULL;
	CString sResult;
	CString sWorkingUrl;
	CString sHeaders = "";
	CString sMsg;
	sErrMsg = "";
	DWORD dwHttpStatus;
	nResult = CROBOT_ERR_SUCCESS;
	TCHAR sTemp[1024];

	try 
	{
		pSession = NULL;
		pConnection = NULL;
		pHttpFile = NULL;
		nRead = 0;
		pBuffer = new char[1024];
		sResult = "";
		sWorkingUrl = sUrl;
		sHeaders = _T("Content-Type: "
					  "application/x-www-form-urlencoded\r\n")
				   + CreateStandardHeader();

		/* 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 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 (HTTP). Now 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_POST,
										sObject,
										sServer,
										1,
										NULL,
										NULL,
										INTERNET_FLAG_EXISTING_CONNECT
											| INTERNET_FLAG_RELOAD
											| INTERNET_FLAG_DONT_CACHE);
				strcpy (sTemp, sData);
				pHttpFile->SendRequest(sHeaders,
									   sTemp,
									   sData.GetLength());
				if (pHttpFile) /* SendRequest 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;
						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 else
			} // End if
			else
				// Wrong service
				nResult = CROBOT_ERR_INVALID_URL;
		} // End if
		else
			// Invalid URL
			nResult = CROBOT_ERR_INVALID_URL;
	} // End try

	catch (CInternetException* e) 
	{
		e->Delete();
		sResponse = sResult;
		
		// 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
// *                *
// *  httpPostFile  *
// *                *
// ******************
// Function: Submits a URL and form data/parameters using
//           the POST method. Retrieves response and outputs
//           it to a file.
//
// Inputs:	sURL              - The URL to access
//								 (example: "www.mysite.com")
//			sData			  - The parameters (or "form data")
//								 to submit
//			sOutputFilespec   - File specification of file to 
//								 create/overwrite
//
// Outputs:	<function_result> - True if data was successfully
//								 retrieved, false otherwise
//			nResult           - Completion code. 0 = success,
//								 n = error (defined in CRobot.h)
//			sErrMsg           - The error message, if nResult != 0

BOOL CRobotInternet::httpPostFile(const CString& sUrl,
								  const CString& sData,
								  const CString& sOutputFilespec,
								  int& nResult,
								  CString& sErrMsg)
{
	CInternetSession* pSession;
	CHttpConnection* pConnection;
	CHttpFile* pHttpFile;
	CString sHeader;
	int nRead;
	LPSTR pBuffer = NULL;
	CString sResult;
	CString sWorkingUrl;
	CString sHeaders = "";
	CFile* pLocalFile;
	char sTemp[1024];
	DWORD dwHttpStatus;
	nResult = CROBOT_ERR_SUCCESS;
	CString sMsg;

	try 
	{
   		pSession = NULL;
		pConnection = NULL;
		pHttpFile = NULL;
		pLocalFile = NULL;
		sHeader = CreateStandardHeader();
		nRead = 0;
		pBuffer = new char[1024];
		sResult = "";
		sWorkingUrl = sUrl;
		sHeaders = _T("Content-Type: "
					  "application/x-www-form-urlencoded\r\n")
				   + CreateStandardHeader();

		/* 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 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 correct (HTTP). 
				   Now make the connection. */
				pSession = new CInternetSession(
										m_sUserAgent,
										1,
										INTERNET_OPEN_TYPE_PRECONFIG);
				pConnection = pSession->GetHttpConnection(sServer,
														  nPort,
														  NULL,
														  NULL);
				
				pHttpFile = pConnection->OpenRequest(
									CHttpConnection::HTTP_VERB_POST,
									sObject,
									NULL,
									1,
									NULL,
									NULL,
									INTERNET_FLAG_EXISTING_CONNECT
										| INTERNET_FLAG_RELOAD
										| INTERNET_FLAG_DONT_CACHE);

				strcpy (sTemp, sData);
				pHttpFile->SendRequest(sHeaders,
									   &sTemp,
									   sData.GetLength());
				if (pHttpFile) /* SendRequest 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);

						do 
						{
							nRead = pHttpFile->Read(pBuffer, 1023);
							if (nRead != 0)
							{
								pBuffer[nRead] = 0;
								pLocalFile->Write(pBuffer, nRead);
							} // End if
						} while (nRead != 0);
					} // End else
				} // End if pHttpFile
				else /* SendRequest failed */
				{
					nResult = CROBOT_ERR_CONNECTION_FAILED;
				}
			} // End if
			else
				// Wrong service
				nResult = CROBOT_ERR_CONNECTION_FAILED;
		} // End if
		else
			// Invalid URL
			nResult = CROBOT_ERR_INVALID_URL;
	} // End try

	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 (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
// *             *
// *  httpError  *
// *             *
// ***************
// Function: Scans an HTML response page for HTTP error codes.
//
// Inputs:	sHTML             - HTML response of a prior Internet
//								 access
//
// Outputs:	<function_result> - True if an error code was detected;
//								 false if no errors were detected in
//								 the response
//			nErrorCode        - HTTP error code, such as 404
//			sErrMsg           - Error message text for nErrorCode,
//								 such as "object not found"

BOOL CRobotInternet::httpError(const CString& sHTML,
							   int& nErrorCode,
							   CString& sErrMsg)
{
	CString sTemp = sHTML;
	int nPos;

	nPos = sTemp.Find("HTTP/1.0 ");
	if (nPos != -1)
		sTemp = sTemp.Mid(nPos + 9, 3);

	if (nPos == -1) 
	{
		nPos = sTemp.Find("HTTP Error ");
		if (nPos != -1)
			sTemp = sTemp.Mid(nPos + 11, 3);
	} // End if

	if (nPos != -1) 
	{
		nErrorCode = atoi(sTemp);
		sErrMsg = ResponseMessage(nErrorCode);
		return true;
	} // End if
	else 
	{
		nErrorCode = 0;
		sErrMsg = "";
		return false;
	} // End else
}


// --------------------------------------------------------------
// ************************ public
// *                      *
// *  ParseServerFromURL  *
// *                      *
// ************************
// Function: Scans a URL and returns the server name portion
//           of the URL
//
// Inputs:	sURL              - A fully qualified URL
//
// Outputs:	<function_result> - The server portion of the URL

CString CRobotInternet::ParseServerFromURL(const CString& sURL)
{
	DWORD dwService;
	INTERNET_PORT nPort;
	CString sServer;
	CString sObject;
	CString sPath;
	CString sTempURL;

	sTempURL = sURL;

	if (sTempURL.Find(":") == -1) 
	{
		if (sTempURL.Left(1) != "/")
			sTempURL = "//" + sTempURL;
		sTempURL = "http:" + sTempURL;
	} // End if

	AfxParseURL(sTempURL,
				dwService,
				sServer,
				sObject,
				nPort);

	return sServer;
}


// --------------------------------------------------------------
// ********************** public
// *                    *
// *  ParsePathFromURL  *
// *                    *
// **********************
// Function: Scans a URL and returns the directory path portion of
//           the URL.
//
// Inputs:	sURL              - a fully qualified URL.
//
// Outputs:	<function_result> - the directory path portion of the URL.

CString CRobotInternet::ParsePathFromURL(const CString& sURL)
{
	DWORD dwService;
	INTERNET_PORT nPort;
	CString sServer;
	CString sObject;
	CString sPath;
	int nPos;
	CString sTempURL;

	sTempURL = sURL;

	if (sTempURL.Find(":") == -1) 
	{
		if (sTempURL.Left(1) != "/")
			sTempURL = "//" + sTempURL;
		sTempURL = "http:" + sTempURL;
	} // End if

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
捆绑调教美女网站视频一区| 欧美一区二区三区思思人| 欧美日韩激情一区二区三区| 欧美一区二区三区小说| 国产精品久久精品日日| 精品一区二区三区免费视频| 欧美一a一片一级一片| 国产欧美日韩不卡| 日日摸夜夜添夜夜添国产精品| 不卡的av中国片| 最新日韩av在线| 经典三级在线一区| 91精品国产综合久久久久久久久久| 国产精品日韩成人| 国产乱人伦偷精品视频不卡 | 亚洲精品日产精品乱码不卡| 国产又黄又大久久| 日韩你懂的在线观看| 日韩va欧美va亚洲va久久| 在线观看日韩高清av| 亚洲婷婷在线视频| 成人黄色电影在线| 国产精品伦理一区二区| 国产精品影视网| 久久久美女艺术照精彩视频福利播放| 香蕉av福利精品导航| 欧美影视一区二区三区| 亚洲摸摸操操av| 91蜜桃婷婷狠狠久久综合9色| 国产三级一区二区| 国产成人综合精品三级| 久久精品人人做人人综合| 男女男精品网站| 日韩一级黄色大片| 免费成人av资源网| 日韩久久精品一区| 国产一区二区h| 国产亚洲1区2区3区| 波多野结衣亚洲| 亚洲少妇屁股交4| 欧美在线免费播放| 日韩电影一区二区三区| 91精品国产品国语在线不卡| 美女视频一区二区| 国产亚洲自拍一区| 色综合一个色综合| 偷拍与自拍一区| 日韩一区二区三区视频| 国产精品一区一区| 国产精品卡一卡二卡三| 91精品1区2区| 视频一区视频二区在线观看| 精品国产一区二区三区四区四| 国产一区 二区| 亚洲欧美日韩一区二区| 欧美日韩国产在线观看| 国产麻豆9l精品三级站| 国产精品卡一卡二| 91精品国产欧美一区二区18| 国产福利一区在线观看| 亚洲免费观看在线观看| 日韩欧美另类在线| 色先锋久久av资源部| 蜜臀av亚洲一区中文字幕| 国产婷婷一区二区| 在线看不卡av| 国产精品一级片| 亚洲一二三专区| 精品国产乱码久久久久久蜜臀| 菠萝蜜视频在线观看一区| 亚洲高清久久久| 久久久www成人免费无遮挡大片| 91免费观看国产| 狠狠v欧美v日韩v亚洲ⅴ| 亚洲品质自拍视频网站| 日韩精品一区二| 在线观看区一区二| 国产成人av电影在线观看| 一区二区三区av电影| 久久久久一区二区三区四区| 欧美色综合天天久久综合精品| 久草在线在线精品观看| 亚洲一二三区不卡| 国产精品毛片高清在线完整版| 欧美老肥妇做.爰bbww| av亚洲产国偷v产偷v自拍| 秋霞av亚洲一区二区三| 亚洲欧美日韩国产成人精品影院| 日韩欧美中文字幕公布| 欧洲精品在线观看| 丰满岳乱妇一区二区三区| 久久精品99国产精品日本| 亚洲一区二区三区在线看| 国产精品伦一区| 国产日韩欧美综合在线| 日韩精品一区二区三区视频 | 51精品秘密在线观看| 91丨九色porny丨蝌蚪| 国产精品一区二区三区网站| 人妖欧美一区二区| 石原莉奈一区二区三区在线观看| 一区二区三区影院| 亚洲人成伊人成综合网小说| 国产精品福利电影一区二区三区四区| 精品欧美乱码久久久久久 | 色网综合在线观看| a级高清视频欧美日韩| 国产成人av影院| 国产精品夜夜嗨| 国产精品一区二区你懂的| 国模套图日韩精品一区二区| 另类小说图片综合网| 免费在线观看一区| 久久99久久久欧美国产| 蜜芽一区二区三区| 色狠狠一区二区| 99久久精品国产一区二区三区| 9i在线看片成人免费| 色综合 综合色| 在线观看日韩毛片| 欧美日韩午夜在线视频| 91精品中文字幕一区二区三区| 制服丝袜亚洲色图| 欧美一级片在线看| 欧美精品一区二区三区蜜桃| 久久久久国产精品厨房| 国产欧美精品日韩区二区麻豆天美| 国产亚洲精品中文字幕| 亚洲同性同志一二三专区| 一区二区在线观看免费视频播放| 亚洲午夜私人影院| 美女脱光内衣内裤视频久久网站| 麻豆极品一区二区三区| 国产在线不卡一卡二卡三卡四卡| 精品亚洲成a人| 成人18精品视频| 欧美在线免费视屏| 日韩一区二区三区高清免费看看| 国产亚洲制服色| 亚洲综合视频在线| 美腿丝袜亚洲色图| 懂色av一区二区三区蜜臀| 色综合天天综合在线视频| 欧美日韩精品系列| 久久亚区不卡日本| 亚洲精品乱码久久久久久日本蜜臀| 丝袜美腿高跟呻吟高潮一区| 九九视频精品免费| 色狠狠综合天天综合综合| 日韩欧美国产一区二区在线播放| 国产精品久久久久一区 | 国产精品成人在线观看| 午夜久久久久久电影| 国产剧情一区在线| 欧美图片一区二区三区| 国产偷国产偷亚洲高清人白洁| 一二三区精品视频| 国产精品白丝jk黑袜喷水| 91黄色激情网站| 日本一区二区三区国色天香| 亚洲va国产va欧美va观看| 成人在线视频首页| 欧美电影在哪看比较好| 成人欧美一区二区三区小说 | 亚洲电影中文字幕在线观看| 国产精品自在在线| 在线播放日韩导航| 亚洲色图欧美激情| 国产伦精品一区二区三区视频青涩| 色中色一区二区| 欧美国产一区二区| 男女性色大片免费观看一区二区| 色综合色狠狠天天综合色| 国产亚洲综合在线| 老司机午夜精品99久久| 欧美性色黄大片| 亚洲欧美日韩在线| 懂色av一区二区夜夜嗨| 精品精品国产高清a毛片牛牛| 亚洲五码中文字幕| 91伊人久久大香线蕉| 国产午夜精品在线观看| 激情都市一区二区| 91精品国产91热久久久做人人| 有码一区二区三区| 精品少妇一区二区三区视频免付费 | 欧美精品一级二级| 亚洲主播在线观看| 97se亚洲国产综合在线| 国产日韩综合av| 国产精品一区二区免费不卡 | 6080日韩午夜伦伦午夜伦| 玉米视频成人免费看| 一本大道久久精品懂色aⅴ| 中文字幕一区二区三区av | 精品一区二区三区在线观看| 7799精品视频| 日韩国产精品久久| 欧美日韩一区二区三区在线| 亚洲大片精品永久免费|