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

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

?? reqsock.cpp

?? 也是個http服務器
?? CPP
?? 第 1 頁 / 共 3 頁
字號:
		cEnv.Add( "SERVER_PORT", strValue );

		cEnv.Add( "REQUEST_METHOD", pRequest->m_strMethod );
		cEnv.Add( "SCRIPT_NAME", pRequest->m_strURL );
		cEnv.Add( "QUERY_STRING", pRequest->m_strArgs );
		cEnv.Add( "REMOTE_ADDR", pRequest->m_strHost );
		if ( pRequest->m_cbBody > 0 )
		{
			cEnv.Add( "CONTENT_LENGTH", pRequest->GetHeaderValue("Content-Length") );
			cEnv.Add( "CONTENT_TYPE", pRequest->GetHeaderValue("Content-Type") );
		}
		if ( !pRequest->m_strPathInfo.IsEmpty() )
		{
			cEnv.Add( "PATH_INFO", pRequest->m_strPathInfo );
			cEnv.Add( "PATH_TRANSLATED", pRequest->m_strPathTranslated );
		}

		// all the passed headers prefixed with "HTTP_"....
		POSITION pos = pRequest->m_mapHeaders.GetStartPosition();
		while ( pos != NULL )
		{
			// get the name/value pair....
			CString strName, strValue;
			pRequest->m_mapHeaders.GetNextAssoc( pos, strName, strValue );
			HeaderToEnvVar( strName );
			// set the environment variable....
			cEnv.Add( strName, strValue );
		}

		// create the process....
		LPVOID pEnv = (LPVOID)cEnv.GetBlock();
		PROCESS_INFORMATION pi;
		STARTUPINFO si = {0};
		si.cb = sizeof(si);
		si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;
		si.wShowWindow = SW_HIDE;
		si.hStdInput = hReadPipe;
		si.hStdOutput = pReqSock->m_hFile;
		si.hStdError = pReqSock->m_hFile;
		bOk = CreateProcess( NULL, strCmdLine.GetBuffer(1),
			NULL, NULL, TRUE,
			dwCreateFlags, pEnv,
			strDir, &si, &pi );
		strCmdLine.ReleaseBuffer();
		// if created....
		if ( bOk )
		{
			// release our hold on the thread....
			CloseHandle( pi.hThread );
			// send the body of the post to the stdin....
			if ( pRequest->m_cbBody > 0 )
			{
				DWORD dwWritten = 0;
				WriteFile( hWritePipe, pRequest->m_baBody.GetData(),
					pRequest->m_cbBody, &dwWritten, NULL );
			}
			// wait for either cancel or process done....
			HANDLE aHandles[2];
			aHandles[0] = pi.hProcess;
			aHandles[1] = pReqSock->m_pCancel->m_hObject;
			if ( WaitForMultipleObjects( 2, aHandles, FALSE, INFINITE ) == WAIT_OBJECT_0 )
			{
				// process finished; notify main thread....
				AfxGetApp()->m_pMainWnd->PostMessage( WSM_CGIDONE, 0, (LPARAM)pReqSock );
			}
			else
			{
				// canceled or some other error....
				bOk = FALSE;
			}
			// close our hold on it....
			CloseHandle( pi.hProcess );
		}
		else
			dwErr = GetLastError();

		// close the stdin pipe....
		CloseHandle( hWritePipe );
		CloseHandle( hReadPipe );
		delete pEnv;
	}
	if ( bOk == FALSE && pReqSock->m_hFile != INVALID_HANDLE_VALUE )
	{ // JIC....
		CloseHandle( pReqSock->m_hFile );
		pReqSock->m_hFile = INVALID_HANDLE_VALUE;
	}

	return (bOk?0:1);
}

void CRequestSocket::CGIDone( void )
{
	if ( !m_bKilled )
	{
		// flush the temp file's buffers....
		BOOL bSucceed = FlushFileBuffers( m_hFile );
		// go to start of file....
		DWORD dwPos = SetFilePointer( m_hFile, 0, NULL, FILE_BEGIN );
		// output the header....
		StuffHeading();
		if ( m_pRequest->m_strMethod.Compare( "HEAD" ) )
			StartTargetStuff();
		else
		{
			CloseHandle( m_hFile );
			m_hFile = INVALID_HANDLE_VALUE;
		}
		AsyncSelect( FD_WRITE | FD_CLOSE );
	}
	else
	{
		CloseHandle( m_hFile );
		m_hFile = INVALID_HANDLE_VALUE;
	}
}

void HeaderToEnvVar( CString& strVar )
{
	int ndx;
	// make upper case, change '-' to '_', and prefix....
	strVar.MakeUpper();
	while( (ndx = strVar.Find('-')) != -1 )
		strVar = strVar.Left(ndx) + '_' + strVar.Mid(ndx+1);
	strVar = "HTTP_" + strVar;
}

CEnvironment::CEnvironment( void )
{
	m_nSize = 2;
}

CEnvironment::~CEnvironment( void )
{
}

BOOL CEnvironment::Add( CString name, CString value )
{
	BOOL bOk = TRUE;
	// create the entry pair string....
	CString strPair = name + __TEXT('=') + value;
	m_nSize += strPair.GetLength() + 1;
	POSITION pos = m_list.GetHeadPosition();

	// find the first item bigger than this string....
	while( pos != NULL )
	{
		if ( m_list.GetAt(pos).CompareNoCase(strPair) > 0 )
		{
			m_list.InsertBefore( pos, strPair );
			break;
		}
		m_list.GetNext( pos );
	}
	if ( pos == NULL )
		m_list.AddTail( strPair );

	return bOk;
}

LPVOID CEnvironment::GetBlock( void )
{
	// allocate a block....
	PTCHAR pBlock = new TCHAR[m_nSize];
	if ( pBlock )
	{
		// iterate through the list....
		PTCHAR pPos = pBlock;
		POSITION pos = m_list.GetHeadPosition();
		while( pos != NULL )
		{
			CString& str = m_list.GetNext( pos );
			// copy the string....
			lstrcpy( pPos, str );
			pPos += str.GetLength() + 1;
		}
		// NULL for the whole list....
		*pPos = __TEXT('\0');
	}
	return pBlock;
}
#endif // IMPL_CGI

CString CRequestSocket::GetHttpDate( LPFILETIME pft )
{
	SYSTEMTIME st;
	if ( pft )
		FileTimeToSystemTime( pft, &st );
	else
		GetSystemTime( &st );

	CTime timeHttp( st );
	return timeHttp.Format( IDS_HTTPTIME );
}

BOOL CRequestSocket::IfModSince( const CTime& timeIfMod )
{
	// assume it has been modified....
	BOOL bOk = TRUE;
	FILETIME ft;
	if ( GetFileTime( m_hFile, NULL, NULL, &ft ) )
	{
		SYSTEMTIME st;
		if ( FileTimeToSystemTime( &ft, &st ) )
		{
			CTime timeFile( st );
			if ( timeFile <= timeIfMod )
				bOk = FALSE;
		}
	}
	return bOk;
}

static int IntVal( CString strVal )
{
	int nVal = 0;
	strVal.TrimLeft();
	for( int ndx = 0; ndx < strVal.GetLength(); ++ndx )
		nVal = nVal*10 + strVal.GetAt(ndx) - '0';

	return nVal;
}

static int MonthFromStr( const CString& str )
{
	LPSTR aMonths[] = {
		"xxx", "jan", "feb", "mar", "apr", "may", "jun",
		"jul", "aug", "sep", "oct", "nov", "dec" };
	for( int nMonth=1; nMonth <= 12; ++nMonth )
	{
		if ( str.CompareNoCase( aMonths[nMonth] ) == 0 )
			break;
	}

	return nMonth;
}

// Dow, dd Mon year hh:mm:ss GMT
BOOL CRequestSocket::FromHttpTime( const CString& strHttp, CTime& timeHttp )
{
	// assume we couldn't get a good time conversion....
	BOOL bOk = FALSE;
	SYSTEMTIME st = {0};
	int ndx;
	switch( strHttp.GetAt(3) )
	{
	case ',':
		// read RFC-1123 (preferred)....
		st.wDay = IntVal( strHttp.Mid(5,2) );
		st.wMonth = MonthFromStr( strHttp.Mid(8,3) );
		st.wYear = IntVal( strHttp.Mid(12,4) );
		st.wHour = IntVal( strHttp.Mid(17,2) );
		st.wMinute = IntVal( strHttp.Mid(20,2) );
		st.wSecond = IntVal( strHttp.Mid(23,2) );
		break;
	case ' ':
		// read ANSI-C time format....
		st.wDay = IntVal( strHttp.Mid(8,2) );
		st.wMonth = MonthFromStr( strHttp.Mid(4,3) );
		st.wYear = IntVal( strHttp.Mid(20,4) );
		st.wHour = IntVal( strHttp.Mid(11,2) );
		st.wMinute = IntVal( strHttp.Mid(14,2) );
		st.wSecond = IntVal( strHttp.Mid(17,2) );
		break;
	default:
		if ( (ndx = strHttp.Find( ", " )) != -1 )
		{
			st.wDay = IntVal( strHttp.Mid(ndx+2,2) );
			st.wMonth = MonthFromStr( strHttp.Mid(ndx+5,3) );
			st.wYear = IntVal( strHttp.Mid(ndx+9,2) );
			st.wHour = IntVal( strHttp.Mid(ndx+12,2) );
			st.wMinute = IntVal( strHttp.Mid(ndx+15,2) );
			st.wSecond = IntVal( strHttp.Mid(ndx+18,2) );
			// add the correct century....
			st.wYear += (st.wYear > 50)?1900:2000;
		}
		break;
	}
	// if year not zero, we pulled the info out of the string....
	if ( st.wYear != 0 )
	{
		// assume GMT....
		CTime strTime( st );
		// check to see if the minutes are the same....
		if ( strTime.GetMinute() == st.wMinute )
		{
			// assume it worked....
			timeHttp = strTime;
			bOk = TRUE;
		}
	}
	return bOk;
}

int CRequestSocket::AddRef( void )
{
	return ++m_nRefs;
}

int CRequestSocket::Release( void )
{
	int nRefs = --m_nRefs;
	if ( nRefs == 0 )
		delete this;
	return nRefs;
}



void CRequestSocket::StuffFileType( void )
{
	// get the extension....
	CString strExt = m_pRequest->m_strFullPath.Mid(
		m_pRequest->m_strFullPath.ReverseFind('.') );
	// find it in the registry....
	HKEY hKey = NULL;
	if ( RegOpenKeyEx( HKEY_CLASSES_ROOT, strExt,
		0, KEY_READ, &hKey ) == ERROR_SUCCESS )
	{
		DWORD dwSize = 0;
		// see how long the data is....
		if ( RegQueryValueEx( hKey, "Content Type", NULL, NULL,
			NULL, &dwSize ) == ERROR_SUCCESS )
		{
			CString strType;
			LONG lRet = RegQueryValueEx( hKey, "Content Type", NULL, NULL,
				(LPBYTE)strType.GetBuffer( dwSize ), &dwSize );
			strType.ReleaseBuffer();
			if ( lRet == ERROR_SUCCESS )
				StuffHeader( "Content-type", strType );
		}
		RegCloseKey( hKey );
	}
}

CString Decode( const CString& str, BOOL bQuery )
{
	int ndx;
	CString strDecoded = str;
	// special processing or query strings....
	if ( bQuery )
	{
		// change all '+' to ' '....
		while( (ndx=strDecoded.Find('+')) != -1 )
			strDecoded = strDecoded.Left(ndx) + ' ' + strDecoded.Mid(ndx+1);
	}

	// first see if there are any %s to decode....
	if ( strDecoded.Find( '%' ) != -1 )
	{
		// iterate through the string, changing %dd to special char....
		for( ndx=0; ndx < strDecoded.GetLength(); ndx++ )
		{
			char ch = strDecoded.GetAt( ndx );
			if ( ch == '%' )
			{
				if ( strDecoded.GetAt( ndx+1 ) == '%' )
				{
					// wanna keep one percent sign....
					strDecoded = strDecoded.Left(ndx) + strDecoded.Mid(ndx+1);
				}
				else
				{
					// assume we have a hex value....
					char ch1 = strDecoded.GetAt(ndx+1);
					char ch2 = strDecoded.GetAt(ndx+2);
					ch1 = ch1 >= 'A' ? (ch1&0xdf)-'A' : ch1-'0';
					ch2 = ch2 >= 'A' ? (ch2&0xdf)-'A' : ch2-'0';
					// replace the escape sequence with the char....
					strDecoded = strDecoded.Left(ndx)
						+ (char)(ch1*16 + ch2)
						+ strDecoded.Mid( ndx+3 );
				}
			}
		}
	}
	return strDecoded;
}

CString CRequestSocket::StripLast( CString& strPath )
{
	CString strExtra;
	if ( !strPath.IsEmpty() )
	{
		int ndx = strPath.ReverseFind( SEPCHAR );
		if ( ndx < 0 )
			ndx = 0;
		strExtra = strPath.Mid( ndx );
		strPath = strPath.Left( ndx );
	}
	return strExtra;
}

BOOL CRequestSocket::CheckDefault( UINT uList, BOOL bExecute )
{
	BOOL bFound = FALSE;
	DWORD dwAttr;
	CString strDefault, strDefList;
	strDefList.LoadString( uList );
	while ( !strDefList.IsEmpty() )
	{
		int ndx;
		strDefault = m_pRequest->m_strFullPath;
		if ( (ndx=strDefList.Find('\n')) == -1 )
		{
			AddFile( strDefault, strDefList );
			strDefList.Empty();
		}
		else
		{
			AddFile( strDefault, strDefList.Left(ndx) );
			strDefList = strDefList.Mid( ndx+1 );
		}
		if ( (dwAttr=GetFileAttributes(strDefault)) != -1 &&
			(dwAttr & FILE_ATTRIBUTE_DIRECTORY) == 0 )
		{
			bFound = TRUE;
			break;
		}
	}
	if ( bFound )
	{
		// redirect to the default file....
		PathToURL( strDefault );
		if ( bExecute )
			strDefault += '?';

		StuffStatus( IDS_STATUS_MOVEDTEMP );
		StuffHeader( "Location", strDefault );
		StuffString( CRLF );
	}
	return bFound;
}

BOOL CRequestSocket::IsSvrApp( void )
{
	BOOL bOk = FALSE;
	int ndx = m_pRequest->m_strFullPath.ReverseFind( '.' );
	if ( ndx != -1 )
	{
		CString strExt = m_pRequest->m_strFullPath.Mid( ndx+1 );
		CString strAvail;
		// check if CGI app....
		strAvail.LoadString( IDS_APP_CGI );
		bOk = CheckExt( strExt, strAvail, CRequest::APP_CGI );
		if ( !bOk )
		{
			strAvail.LoadString( IDS_APP_ISAPI );
			bOk = CheckExt( strExt, strAvail, CRequest::APP_ISAPI );
		}
	}

	return bOk;
}

BOOL CRequestSocket::CheckExt( const CString& strExt, CString& strAvail, DWORD dwType )
{
	BOOL bMatch = FALSE;
	CString strPossible;
	// loop through all possible exts....
	while( !strAvail.IsEmpty() )
	{
		int ndx = strAvail.ReverseFind('\n');
		if ( ndx == -1 )
		{
			strPossible = strAvail;
			strAvail.Empty();
		}
		else
		{
			strPossible = strAvail.Mid( ndx+1 );
			strAvail = strAvail.Left( ndx );
		}
		if ( strExt.CompareNoCase( strPossible ) == 0 )
		{
			m_pRequest->m_dwExecute = dwType;
			bMatch = TRUE;
			break;
		}
	}
	return bMatch;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲一区二区三区小说| 久久99久久精品| 国产精品成人免费| 2021国产精品久久精品| 欧美人牲a欧美精品| 色素色在线综合| 成人高清av在线| 国产成人综合视频| 蜜臂av日日欢夜夜爽一区| 亚洲男人天堂av网| 久久亚区不卡日本| 精品嫩草影院久久| 26uuu亚洲综合色欧美 | 国产99精品视频| 久久疯狂做爰流白浆xx| 蜜臀av性久久久久蜜臀av麻豆| 午夜一区二区三区视频| 亚洲黄一区二区三区| 亚洲欧美日韩久久| 亚洲乱码中文字幕| 亚洲影视在线观看| 亚洲国产人成综合网站| 亚洲va韩国va欧美va精品| 亚洲国产日韩a在线播放性色| 洋洋成人永久网站入口| 亚洲成人一区二区在线观看| 亚洲国产电影在线观看| 亚洲综合免费观看高清完整版| 亚洲黄色性网站| 亚洲午夜av在线| 日韩中文欧美在线| 国产欧美日韩在线| 国产精品二三区| 国产目拍亚洲精品99久久精品| 久久久久久久久久美女| 国产日韩欧美高清| 色狠狠色狠狠综合| 日韩亚洲欧美中文三级| 欧美成人在线直播| 国产欧美一区二区三区在线看蜜臀| 久久久国际精品| www国产成人免费观看视频 深夜成人网| 欧美精品一区二区三区久久久| 国产夜色精品一区二区av| 久久精品视频一区二区| 亚洲欧洲精品一区二区三区不卡| 日本一区二区免费在线观看视频 | 欧美精品一区二区三区四区| 国产日韩精品一区二区三区在线| 91麻豆精品国产无毒不卡在线观看 | 欧美日韩视频在线一区二区| 91麻豆精品91久久久久同性| 精品国产伦理网| 中文字幕在线观看一区二区| 1024成人网色www| 亚洲一级片在线观看| 天天色天天操综合| 国产精品一区久久久久| 色综合中文综合网| 国产精品人成在线观看免费 | 一区二区三区国产豹纹内裤在线| 日韩二区三区四区| 国产乱码精品一区二区三区av| av成人免费在线观看| 欧美人狂配大交3d怪物一区| 精品国产乱码久久久久久蜜臀| 国产精品福利一区二区三区| 亚洲一区影音先锋| 一区二区三区欧美| 韩国毛片一区二区三区| 欧美综合色免费| 日韩欧美一卡二卡| 亚洲三级理论片| 成人免费看黄yyy456| 奇米777欧美一区二区| 成人av网址在线| 欧美区一区二区三区| ●精品国产综合乱码久久久久| 天堂va蜜桃一区二区三区| 国产精品二三区| 久久精品在线观看| 丝袜亚洲另类欧美综合| 91成人在线精品| 国产欧美一区二区三区在线看蜜臀 | 日本一道高清亚洲日美韩| 在线一区二区视频| 久久先锋影音av鲁色资源网| 一区二区免费在线播放| eeuss鲁片一区二区三区 | 欧美精品一二三四| 亚洲精品国产成人久久av盗摄 | 亚洲人午夜精品天堂一二香蕉| 国内久久婷婷综合| 欧美一区二区视频在线观看 | 成人黄色小视频| 欧美大胆人体bbbb| 美国一区二区三区在线播放| 欧美性高清videossexo| 国产午夜亚洲精品羞羞网站| 毛片一区二区三区| 制服丝袜日韩国产| 蜜臀久久99精品久久久画质超高清 | 夜夜夜精品看看| 国产不卡在线视频| 中文字幕第一区综合| 韩国av一区二区| 久久久精品日韩欧美| 麻豆精品久久精品色综合| 成人av免费观看| 18欧美乱大交hd1984| 成人av在线网站| 亚洲欧美视频一区| 久久99国产乱子伦精品免费| 91精品婷婷国产综合久久性色| 悠悠色在线精品| 欧美日韩美少妇| 秋霞午夜av一区二区三区| 久久久国产精华| 欧美在线一二三四区| 亚洲国产精品二十页| 成人的网站免费观看| 亚洲日本韩国一区| 在线欧美日韩国产| 国产成人免费视频网站高清观看视频| 日本一区二区电影| 欧美成人video| 在线视频一区二区免费| 国产一区二区在线影院| 一区二区三区中文在线观看| 高清国产一区二区三区| 亚洲视频资源在线| 日韩视频免费直播| 99久免费精品视频在线观看| 日本中文在线一区| 在线综合+亚洲+欧美中文字幕| 精久久久久久久久久久| 欧美性色黄大片| 亚洲综合色视频| 中文字幕一区二区三区色视频| 色婷婷精品久久二区二区蜜臂av | 91精品午夜视频| 开心九九激情九九欧美日韩精美视频电影| 精品免费日韩av| 欧美日韩一级视频| www.激情成人| 粉嫩av一区二区三区粉嫩| 亚洲一区二区三区自拍| 亚洲gay无套男同| 天天操天天色综合| 国产丶欧美丶日本不卡视频| 色网综合在线观看| 亚洲成人一区在线| 精品日韩一区二区| 久久综合色一综合色88| 成人动漫精品一区二区| 天天综合网 天天综合色| 欧美日韩一本到| 蜜乳av一区二区| 亚洲精品高清在线| 日韩欧美国产电影| 在线看国产日韩| 国产尤物一区二区| 国产精品亲子伦对白| 欧美三级资源在线| 国产在线精品免费| 亚洲第四色夜色| 国产亚洲一区二区三区| 欧美日韩国产区一| 国产精品12区| 亚洲欧美日本韩国| 国产婷婷一区二区| 欧美在线啊v一区| 成人激情动漫在线观看| 五月婷婷另类国产| 一区二区三区四区不卡视频| 久久夜色精品国产欧美乱极品| 91麻豆国产自产在线观看| 国产九九视频一区二区三区| 亚洲成人激情综合网| 中文字幕日本不卡| 亚洲精品在线免费播放| 欧美日本不卡视频| 国产精品资源在线看| 1区2区3区精品视频| xnxx国产精品| 欧美一区二区视频免费观看| 欧美性极品少妇| 99re热视频精品| 粉嫩绯色av一区二区在线观看| 99久久99久久久精品齐齐| 久久婷婷国产综合国色天香| 狠狠狠色丁香婷婷综合激情 | 五月综合激情日本mⅴ| 在线观看视频一区| 亚洲成人激情av| 国产精品久久久久久亚洲毛片 | 91亚洲精品久久久蜜桃| 91福利在线看| 依依成人精品视频| 91在线精品一区二区|