agent/browser/ie/pagetest/PagetestReporting.cpp
/*-----------------------------------------------------------------------------
	Log the 404's from the page if we have been asked to
-----------------------------------------------------------------------------*/
Log the 404's from the page if we have been asked to
Log the 404 ' s from the page if we have been asked to
void CPagetestReporting::Log404s()
{
	if( !s404File.IsEmpty() )
	{
		CStringA s404;
		POSITION pos = events.GetHeadPosition();
		while( pos )
		{
			CTrackedEvent * e = events.GetNext(pos);
			if( e && e->type == CTrackedEvent::etWinInetRequest )
			{
				CWinInetRequest * w = (CWinInetRequest *)e;
				if( w->result == 404 )
				{
					CString buff;
					CString obUrl = w->host + w->object;
					buff.Format(_T("%s\t%s\r\n"), logUrl, (LPCTSTR)obUrl);
					s404 += buff;
				}
			}
		}
		if( !s404.IsEmpty() )
		{
			HANDLE hFile = INVALID_HANDLE_VALUE;
			do
			{
				hFile = CreateFile(s404File, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, &nullDacl, OPEN_ALWAYS, 0, 0);
				if( hFile == INVALID_HANDLE_VALUE )
					Sleep(10);
			}while( hFile == INVALID_HANDLE_VALUE );
			if( hFile != INVALID_HANDLE_VALUE )
			{
				SetFilePointer(hFile, 0, 0, FILE_END);
				DWORD bytes;
				WriteFile(hFile, (LPCSTR)s404, s404.GetLength(), &bytes, 0);
				CloseHandle(hFile);
			}
		}
	}
}
void CPagetestReporting :: Log404s ( ) { if ( ! s404File . IsEmpty ( ) ) { CStringA s404 ; POSITION pos = events . GetHeadPosition ( ) ; while ( pos ) { CTrackedEvent * e = events . GetNext ( pos ) ; if ( e && e -> type == CTrackedEvent :: etWinInetRequest ) { CWinInetRequest * w = ( CWinInetRequest * ) e ; if ( w -> result == 404 ) { CString buff ; CString obUrl = w -> host + w -> object ; buff . Format ( _T ( " \t \r \n " ) , logUrl , ( LPCTSTR ) obUrl ) ; s404 += buff ; } } } if ( ! s404 . IsEmpty ( ) ) { HANDLE hFile = INVALID_HANDLE_VALUE ; do { hFile = CreateFile ( s404File , GENERIC_READ | GENERIC_WRITE , FILE_SHARE_READ , & nullDacl , OPEN_ALWAYS , 0 , 0 ) ; if ( hFile == INVALID_HANDLE_VALUE ) Sleep ( 10 ) ; } while ( hFile == INVALID_HANDLE_VALUE ) ; if ( hFile != INVALID_HANDLE_VALUE ) { SetFilePointer ( hFile , 0 , 0 , FILE_END ) ; DWORD bytes ; WriteFile ( hFile , ( LPCSTR ) s404 , s404 . GetLength ( ) , & bytes , 0 ) ; CloseHandle ( hFile ) ; } } } }
Log the 404's from the page if we have been asked to
Log the 404 ' s from the page if we have been asked to
// walk the list of requests looking for 404's
 // write out the report if we have one
