agent/browser/ie/pagetest/PagetestReporting.cpp
/*-----------------------------------------------------------------------------
	Check to make sure cookies are not set to the TLD
-----------------------------------------------------------------------------*/
Check to make sure cookies are not set to the TLD
Check to make sure cookies are not set to the TLD
void CPagetestReporting::CheckCookie()
{
	cookieScore = -1;
	int count = 0;
	int total = 0;
	DWORD totalBytes = 0;
	DWORD targetBytes = 0;
	ATLTRACE(_T("[Pagetest] - CheckCookie\n"));
	POSITION pos = events.GetHeadPosition();
	while( pos )
	{
		CTrackedEvent * e = events.GetNext(pos);
		if( e && e->type == CTrackedEvent::etWinInetRequest && !e->ignore )
		{
			CWinInetRequest * w = (CWinInetRequest *)e;
			CString mime = w->response.contentType;
			mime.MakeLower();
			CString exp = w->response.expires;
			exp.Trim();
			CString cache = w->response.cacheControl;
			cache.MakeLower();
			CString pragma = w->response.pragma;
			pragma.MakeLower();
			CString object = w->object;
			object.MakeLower();
			count++;
			int cnt = 0;
			CString failStr;
			w->cookieScore = 100;
			if( w->fromNet && w->request.cookieSize )
			{
				totalBytes += w->request.cookieSize;
				if( (w->result == 304 ||
					w->result == 200) &&
					exp != _T("0") && 
					exp != _T("-1") && 
					!(cache.Find(_T("no-store")) > -1) &&
					!(cache.Find(_T("no-cache")) > -1) &&
					!(pragma.Find(_T("no-cache")) > -1) &&
					!(mime.Find(_T("/html")) > -1)	&&
					!(mime.Find(_T("/xhtml")) > -1)	&&
					(	mime.Find(_T("shockwave-flash")) >= 0 || 
						object.Right(4) == _T(".swf") ||
						mime.Find(_T("text/")) >= 0 || 
						mime.Find(_T("javascript")) >= 0 || 
						mime.Find(_T("image/")) >= 0) )
				{
					w->cookieScore = 0;
				}
				else
				{
					w->cookieScore = 50;
					targetBytes += w->request.cookieSize;
				}
			}
			if( !w->cookieScore )
				w->warning = true;
			total += w->cookieScore;
		}
	}
	if( count )
		cookieScore = total / count;
}
void CPagetestReporting :: CheckCookie ( ) { cookieScore = -1 ; int count = 0 ; int total = 0 ; DWORD totalBytes = 0 ; DWORD targetBytes = 0 ; ATLTRACE ( _T ( " \n " ) ) ; POSITION pos = events . GetHeadPosition ( ) ; while ( pos ) { CTrackedEvent * e = events . GetNext ( pos ) ; if ( e && e -> type == CTrackedEvent :: etWinInetRequest && ! e -> ignore ) { CWinInetRequest * w = ( CWinInetRequest * ) e ; CString mime = w -> response . contentType ; mime . MakeLower ( ) ; CString exp = w -> response . expires ; exp . Trim ( ) ; CString cache = w -> response . cacheControl ; cache . MakeLower ( ) ; CString pragma = w -> response . pragma ; pragma . MakeLower ( ) ; CString object = w -> object ; object . MakeLower ( ) ; count ++ ; int cnt = 0 ; CString failStr ; w -> cookieScore = 100 ; if ( w -> fromNet && w -> request . cookieSize ) { totalBytes += w -> request . cookieSize ; if ( ( w -> result == 304 || w -> result == 200 ) && exp != _T ( " " ) && exp != _T ( " " ) && ! ( cache . Find ( _T ( " " ) ) > -1 ) && ! ( cache . Find ( _T ( " " ) ) > -1 ) && ! ( pragma . Find ( _T ( " " ) ) > -1 ) && ! ( mime . Find ( _T ( " " ) ) > -1 ) && ! ( mime . Find ( _T ( " " ) ) > -1 ) && ( mime . Find ( _T ( " " ) ) >= 0 || object . Right ( 4 ) == _T ( " " ) || mime . Find ( _T ( " " ) ) >= 0 || mime . Find ( _T ( " " ) ) >= 0 || mime . Find ( _T ( " " ) ) >= 0 ) ) { w -> cookieScore = 0 ; } else { w -> cookieScore = 50 ; targetBytes += w -> request . cookieSize ; } } if ( ! w -> cookieScore ) w -> warning = true ; total += w -> cookieScore ; } } if ( count ) cookieScore = total / count ; }
Check to make sure cookies are not set to the TLD
Check to make sure cookies are not set to the TLD
// default to pass
 // see if there were any cookies on the request
 // if it is a static object then it fails outright
 // average the cookie scores of all of the objects for the page
