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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? httpresponse.cpp

?? 一個c++實現(xiàn)的acd的例子。 ----ACDCommandListener.cpp ---ACDCommandListenerThread.cpp ---ACDConfig.cpp ---a
?? CPP
字號:
#include "stdafx.h"


#include "HttpResponse.h"
#include "TimeStamp.h"
//#include "../acdx.h"

#pragma warning( disable:4800 )

class ACDX;


// static link to server
//##ModelId=424BB64401BE
HttpServerInfo *  HttpResponse::_server = NULL;


//////////////////////////////////////////////////////////////////////////////////
// HttpResponse

//##ModelId=424BB64401E1
HttpResponse::HttpResponse () :
	HttpRequest(),

	//_hFile(0)
	_file()

{
		//acdx = ACDX::getInstance();
	}


//##ModelId=424BB64401EC
HttpResponse::HttpResponse ( HttpRequest & request ) :
	HttpRequest(),

	//_hFile(0)
	_file()

{
	setState(request);
	//acdx = ACDX::getInstance();
}


//##ModelId=424BB64401EE
HttpResponse::~HttpResponse ()
{
	release();
}

// create/release
//##ModelId=424BB64401FB
bool HttpResponse::create ()
{
	// perform init
	//_hFile = 0;
	_file.create();

	return true;
}

//##ModelId=424BB64401FC
void HttpResponse::release ()
{
	// cleanup request
	HttpRequest::release();

	// cleanup file
	_file.release();
	/*
	if ( _hFile )
	{
		// close file
		CloseHandle(_hFile);
	}
	*/
}

//##ModelId=424BB644020E
bool HttpResponse::startServerApp ()
{
	addError( idHttpInternalError );
	return false;
}


// add acdx logic for user login and logout logic [3/29/2005]
// login and logout show page
//##ModelId=424BB644020D
bool HttpResponse::startResponse ()
{
	bool bWait = false;

	// save the host address
	//UINT uPort;
	//getpeername( getHost(), uPort );

	// switch on the method
	string strFile;

	string method = getMethod();

	// to user logout
	if (HttpUtil::isGetCmd(method)) {
		if (((*this).getUrl()).compare("/logout")==0) 
		{
			string userName = (*this).getArgs();
			(_server->acdx)->logout(CString(userName.c_str()));
//			acdx->logout(CString(userName.c_str()));
			addString( "--------> "+userName+" logout !" );
			
			_server->hit( *this );
			return bWait;
		}
	}
	if (HttpUtil::isGetCmd(method)) {
		if (((*this).getUrl()).compare("/login")==0) 
		{
			string userName = (*this).getArgs();
			(_server->acdx)->login(userName.c_str());
			addString( "--------> "+userName+" login !" );

			_server->hit( *this );
			return bWait;
		}
	}
	if (HttpUtil::isGetCmd(method)) {
		if (((*this).getUrl()).compare("/status")==0) 
		{
			//string userName = (*this).getArgs();

			CString agent_States		= (_server->acdx)->dumpAgentStates();
			CString agent_PendingList	= (_server->acdx)->dumpPendingList();
			addString( "--------><br>"+agent_States+"<br>"+agent_PendingList );

			_server->hit( *this );
			return bWait;
		}
	}



	if ( size() == 0 && HttpUtil::isGetCmd(method) )
	{
		_server->find( *this, strFile );

		if( getStatus() == idHttpOk )
		{
			if ( getExecute() )
				bWait = startServerApp();
			else
			{
				if ( addHeading() )
					addTagetInfo();
			}
		}
	}
	else if ( size() == 0 && getProcessState() == REQ_DONE &&
		      HttpUtil::isHeadCmd(method) )
	{
		_server->find( *this, strFile );

		if( getStatus() == idHttpOk )
		{
			if ( getExecute() )
				bWait = startServerApp();
			else
			{
				addHeading();

				// we don't send the file for HEAD reqs
				/*
				if ( _hFile != INVALID_HANDLE_VALUE)
				{
					CloseHandle( _hFile );
					_hFile = INVALID_HANDLE_VALUE;
				}
				*/
				if ( _file.isValid() )
				{
					_file.close();
				}
			}
		}
	}
	else if ( size() > 0 && getProcessState() == REQ_DONE &&
			  HttpUtil::isPostCmd(method) )
	{
		// assume an executable
		setExecute( idAppExecute );
		_server->find( *this, strFile );
		if ( getStatus() == idHttpOk )
		{
			bWait=startServerApp();
		}
	}
	// if we send acdx infor no need below code they will to 404
	else
		addError( idHttpInternalError );

	// notify server of hit
	_server->hit( *this );

	return bWait;
}


//##ModelId=424BB644021B
bool HttpResponse::addHeading ()
{
	bool more = false;

	if ( getAttributes() & FILE_ATTRIBUTE_HIDDEN )
	{
		// never show hidden files
		addError( idHttpForbidden );
	}
	else if ( getAttributes() & FILE_ATTRIBUTE_DIRECTORY )
	{
		if ( _server->getAllowListing() )
		{
			// create a directory listing
			addStatus( idHttpOk );
			addString( CRLF );
			more = true;
		}
		else
			addError( idHttpForbidden );
	}
	else
	{
		// get file name
		LPCTSTR fileName = getFullPath().c_str();

		// open the file

		/*
		_hFile = 
		CreateFile( fileName,
			        GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
			        FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN,
					NULL ); 

		if ( _hFile != INVALID_HANDLE_VALUE )
		*/
		if ( _file.openFastRead(getFullPath()) )
		{
			if ( getStatus() != REQ_SIMPLE )
			{
				TimeStamp timeIfMod;

				string strIfMod = getHeaderValue( idParamIfModifiedSince );

				if ( strIfMod.size() > 0 &&
					 HttpUtil::fromHttpTime( strIfMod, timeIfMod ) &&
					 !HttpUtil::ifModSince( _hFile, timeIfMod ) )
				{
					// eh, it hasn't been modified
					addStatus( idHttpNotModified );

					// don't need it anymore
					CloseHandle( _hFile );
					_hFile = INVALID_HANDLE_VALUE;
				}
				else
				{
					// send it off
					addStatus( idHttpOk );

					// set content type and length
					long contentLength = GetFileSize( _hFile, NULL );
					addContentType();
					addHeader( idParamContentLength, contentLength );

					// get the last modified time
					FILETIME ft;
					if ( GetFileTime( _file, NULL, NULL, &ft ) )
					{
						string strTime = HttpUtil::getHttpDate( &ft );
						addHeader( idParamLastModified, strTime );
					}

					more = true;
				}

				// blank line
				addString( CRLF );
			}
			else
			{
				more = true;
			}
		}
		else
		{
			// couldn't open; try again later
			addError( idHttpUnavailable );
		}
	}
	return more;
}

//##ModelId=424BB644021C
void HttpResponse::addTagetInfo ()
{
	// #DGH
	// need to get readfile corrrect

	//if ( _hFile != INVALID_HANDLE_VALUE)
	if ( _file.isValid() )
	{
		DWORD dwRead = 0;

		// get file size
		DWORD dwSize =
		//::GetFileSize(_hFile, NULL);
		_file.size();

		// if bytes in file
		if ( dwSize != 0 )
		{
			// set size to send
			//setSizeToSend( dwSize );

			// add null terminator to size (easier for debugging)
			//dwSize++;

			// get buffer
			string tmp;
			LPTSTR buffer = StringUtil::getBufferString(tmp,dwSize);

			// null terminate
			//buffer[dwSize] = '\0';

			// read the first chunk
			dwRead = _file.read( buffer, dwSize );
			//ReadFile( _hFile, buffer, dwSize, &dwRead, NULL );

			if ( dwRead > 0 )
			{
				addString( tmp );
				addString( CRLF );
			}
			else
			{
				// nothing read close the file
				_file.close();
				//CloseHandle( _hFile );
				//_hFile = INVALID_HANDLE_VALUE;
			}
		}
	}
	else if ( getAttributes() & FILE_ATTRIBUTE_DIRECTORY )
		addListing();
	else
		addString( CRLF );
}

//##ModelId=424BB644021D
void HttpResponse::addListing ()
{
	bool bRoot = false;
	bool bIcons = _server->getListIcon();
	string strIcon;

	string strLine = 
	string("http://") 
		+ _server->getServer()
		+ getUrl();

	string strDir  = getUrl();
	string strMask = getFullPath();

	// make sure URL ends in a slash
	if ( strDir[ strDir.size()-1 ] != '/' )
		strDir += '/';

	// is this the server's root folder?
	else if ( strDir.compare( "/" ) == 0 )
		bRoot = true;

	// create the file search mask
	HttpUtil::addFile( strMask, IDS_DIRMASK );

	addString( IDS_CONTENTS_PRE );
	addString( strLine );
	addString( IDS_CONTENTS_POST );

	if ( bRoot )
		addString( IDS_CONTENTS_DESC );

	if ( bIcons )
		StringUtil::loadString( strIcon, IDS_ICON_BLANK );

	StringUtil::formatString( strLine, IDS_CONTENTS_HEADING, strIcon );
	addString( strLine );

	int nFiles = 0;

	WIN32_FIND_DATA fd;

	// find the first file that matches the mask
	HANDLE fh = FindFirstFile( strMask.c_str(), &fd );
	if ( fh != INVALID_HANDLE_VALUE )
	{
		// create a line for the found file
		nFiles += addListingFile( &fd, strDir, bIcons );

		// loop through all other files
		while ( FindNextFile( fh, &fd ) )
			nFiles += addListingFile( &fd, strDir, bIcons );
	}

	if ( nFiles == 0 )
		addString( IDS_CONTENTS_EMPTY );

	addString( IDS_CONTENTS_FOOTER );
	// only add the parent link if there is one
	if ( !bRoot )
	{
		if ( bIcons )
		{
			StringUtil::loadString( strIcon, IDS_ICON_PARENT );
		}

		StringUtil::formatString( strLine, IDS_CONTENTS_PARENT, strIcon );
		addString( strLine );
	}
	// add the note and end it
	addString( IDS_CONTENTS_NOTE );
	addString( CRLF );
}

//##ModelId=424BB644022A
int HttpResponse::addListingFile ( WIN32_FIND_DATA * pfd, 
								   const string& strDir, 
								   bool bIcons )
{
	int nFile = 0;

	// don't include '.', '..' or hidden files
	if ( lstrcmp( pfd->cFileName, "." ) && lstrcmp( pfd->cFileName, ".." )
		&& (pfd->dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) == 0 )
	{
		string strSize, strIcon = "";
		string strLine, strFile = pfd->cFileName;

		TimeStamp timeFile( pfd->ftLastWriteTime );

		bool bFolder = ((pfd->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0);
		if ( bIcons && bFolder )
			StringUtil::loadString( strIcon, IDS_ICON_FOLDER );
		else if ( bIcons )
			StringUtil::loadString( strIcon, IDS_ICON_FILE );

		// create the link string
		string strLink = strDir + strFile;

		// make sure spaces are replaced with '%20'
		int index;
		while ( (index=strLink.find(' ')) != -1 )
			strLink = StringUtil::left(strLink,index) + "%20" + StringUtil::mid(strLink,index+1);

		// format the size string
		if ( bFolder )
			strSize = "  Folder";
		else if ( pfd->nFileSizeHigh > 0 )
			strSize = "   &gt; 4GB"; // yeah, right.
		else if ( pfd->nFileSizeLow < 1024 )
			strSize = "    &lt; 1K";
		else
			StringUtil::formatString( strSize, "%7dK", pfd->nFileSizeLow/1024 );

		
		StringUtil::formatString( strLine, 
								  IDS_CONTENTS_FORMAT,
								  timeFile.format( IDS_FILETIMEFMT ),
								  strSize, strLink, strIcon, strFile );
		

		addString( strLine );

		nFile = 1;
	}
	return nFile;
}

//##ModelId=424BB644023A
void HttpResponse::addContentType ()
{
	// get the extension
	string fullPath = getFullPath();
	string strExt   = StringUtil::mid( fullPath, fullPath.rfind('.') );

	// add content type
	string strType = "";
	if ( StringUtil::compareNoCase(strExt,".html") )
		strType = "text/html";
	else if ( StringUtil::compareNoCase(strExt,".xml") )
		strType = "text/xml";

	if ( !strType.empty() )
		addHeader( idParamContentType, strType );

}




/*
// create/release

bool HttpResponse::create ()
{
	// get response stream
	string & srchStr = _responseStrm.str();
	cout << srchStr;

	// set token string
	string tokenStr = "\r\n";

	// get response
	long first = 0; long last = 0;
	if ( !getParam(first,last,tokenStr,srchStr,_response) )
		return false;

	// get header
	if ( !getParam(first,last,tokenStr,srchStr,_header) )
		return true;


	// get response header
	if ( !getParam(first,last,tokenStr,srchStr,_responseHeader) )
		return true;

	// get response header
	if ( !getParam(first,last,tokenStr,srchStr,_entityHeader) )
		return true;

	// get response header
	if ( !getParam(first,last,tokenStr,srchStr,_entityBody) )
		return true;


	return true;
}


*/

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美国产一区视频在线观看| 依依成人综合视频| 国产精品国产三级国产普通话99| 亚洲男人电影天堂| 国产酒店精品激情| 欧美色大人视频| 国产精品毛片高清在线完整版| 亚洲成人免费av| 99久久国产综合精品色伊| 日韩一卡二卡三卡国产欧美| 日韩一区在线免费观看| 精品一区二区三区免费播放 | 成人美女视频在线观看| 欧美一区午夜视频在线观看| 亚洲美女淫视频| 国产suv精品一区二区三区| 日韩一卡二卡三卡| 日韩精品乱码免费| 欧美性欧美巨大黑白大战| 国产精品乱码人人做人人爱 | 成+人+亚洲+综合天堂| 2020国产精品久久精品美国| 免费在线观看不卡| 欧美精品色一区二区三区| 一个色在线综合| 91福利在线看| 一区二区三区四区视频精品免费 | 免费高清在线一区| 91麻豆精品国产91久久久更新时间| 亚洲美女屁股眼交| av网站免费线看精品| 中文字幕第一区综合| 国产a精品视频| 久久久久亚洲蜜桃| 国产成人在线电影| 国产欧美日韩三级| 精品一区二区三区的国产在线播放 | 香蕉久久夜色精品国产使用方法| 色综合久久久久网| 欧美极品美女视频| 国产激情一区二区三区四区 | 成人动漫一区二区三区| 久久九九影视网| 成人黄色av网站在线| 国产精品乱人伦| 欧美亚洲愉拍一区二区| 天涯成人国产亚洲精品一区av| 欧美精品欧美精品系列| 久久精品国产999大香线蕉| 精品成人佐山爱一区二区| 国产毛片精品国产一区二区三区| 国产欧美一区二区精品性色超碰| 成人免费观看视频| 亚洲精品免费电影| 欧美老肥妇做.爰bbww| 麻豆国产精品一区二区三区| 久久影院视频免费| 99久久久久免费精品国产| 亚洲国产乱码最新视频| 日韩视频在线你懂得| 粉嫩aⅴ一区二区三区四区| 亚洲人成网站在线| 日韩精品专区在线影院重磅| 国产福利一区二区三区视频在线 | 国产日韩精品一区二区浪潮av | 久久se这里有精品| 亚洲视频综合在线| 日韩女优视频免费观看| 91在线小视频| 丝袜亚洲另类欧美综合| 亚洲国产高清不卡| 欧美日韩国产高清一区二区| 韩国女主播一区| 亚洲精品大片www| 精品国产91乱码一区二区三区| 菠萝蜜视频在线观看一区| 三级亚洲高清视频| 国产精品欧美久久久久一区二区| 欧美午夜在线一二页| 国产精品一品二品| 日日夜夜一区二区| 国产精品麻豆视频| 欧美一区二区三区公司| 99久久精品国产毛片| 精品系列免费在线观看| 亚洲影视在线播放| 国产精品网站一区| 欧美一区二区精美| 91黄视频在线| 成人激情免费视频| 精品一区二区三区影院在线午夜| 一区二区三区高清在线| 久久精品视频在线看| 欧美疯狂做受xxxx富婆| 色综合久久中文综合久久牛| 国产精品1区2区3区| 免费在线成人网| 亚洲一区二区精品久久av| 中文字幕精品一区二区三区精品| 欧美巨大另类极品videosbest | 国产一区二区三区| 日韩国产欧美视频| 亚洲午夜在线视频| 亚洲欧洲成人精品av97| 国产欧美日韩卡一| 国产午夜亚洲精品不卡| 精品久久人人做人人爽| 91精品欧美福利在线观看| 欧美亚洲自拍偷拍| 欧美日韩综合不卡| 在线观看日韩av先锋影音电影院| 99riav久久精品riav| 99免费精品在线观看| 成人高清视频在线| eeuss鲁片一区二区三区| 成人aa视频在线观看| 成人精品小蝌蚪| 成人国产精品免费| 不卡的av电影| 日本丶国产丶欧美色综合| 在线观看国产一区二区| 91国产丝袜在线播放| 欧美中文一区二区三区| 欧美日韩亚洲国产综合| 欧美精品丝袜久久久中文字幕| 欧美一区二区福利视频| 欧美成人精品1314www| 精品播放一区二区| 国产精品丝袜黑色高跟| 亚洲同性gay激情无套| 樱桃国产成人精品视频| 三级欧美在线一区| 国产乱码精品一品二品| 风流少妇一区二区| 99国产精品国产精品毛片| 欧美揉bbbbb揉bbbbb| 日韩一区二区电影在线| 亚洲国产精品av| 亚洲不卡在线观看| 久久国产尿小便嘘嘘尿| 国产成人av电影在线| 在线中文字幕一区| 欧美大黄免费观看| 国产精品毛片无遮挡高清| 亚洲成av人片在线观看无码| 九九热在线视频观看这里只有精品| 国产精品一线二线三线| 色吊一区二区三区| 日韩欧美色综合网站| 国产精品国产a级| 男女男精品视频网| caoporen国产精品视频| 欧美老女人第四色| 国产精品第13页| 青青青爽久久午夜综合久久午夜| 粉嫩高潮美女一区二区三区| 欧美三级中文字幕| 久久久精品欧美丰满| 午夜精品久久久久久久蜜桃app| 国产自产高清不卡| 在线观看www91| 国产日本欧美一区二区| 午夜精品福利一区二区三区蜜桃| 国产真实乱子伦精品视频| 一本色道久久综合亚洲精品按摩| 日韩一区二区三区免费观看| 亚洲丝袜精品丝袜在线| 国模娜娜一区二区三区| 欧美另类z0zxhd电影| 国产精品久久久久久久久久久免费看| 午夜婷婷国产麻豆精品| heyzo一本久久综合| 精品第一国产综合精品aⅴ| 亚洲成人1区2区| 99久久综合色| 欧美国产日韩a欧美在线观看| 热久久免费视频| 欧美午夜电影网| 亚洲蜜臀av乱码久久精品| 成人综合激情网| 久久人人爽爽爽人久久久| 丝袜亚洲另类欧美| 欧美日韩日日夜夜| 一区二区三区在线观看动漫| av午夜一区麻豆| 国产精品水嫩水嫩| 国产69精品久久久久777| 精品国产91乱码一区二区三区| 日本sm残虐另类| 日韩欧美激情一区| 亚洲成人激情社区| 欧美视频自拍偷拍| 亚洲一卡二卡三卡四卡无卡久久| 99久久精品国产精品久久| 最新中文字幕一区二区三区| aaa亚洲精品| 亚洲欧洲精品成人久久奇米网| 成人av影视在线观看| 国产精品久久精品日日| 成人va在线观看|