agent/browser/ie/pagetest/PagetestReporting.cpp
/*-----------------------------------------------------------------------------
	Make sure any host that served more than one asset used keep-alives
-----------------------------------------------------------------------------*/
Make sure any host that served more than one asset used keep-alives
Make sure any host that served more than one asset used keep - alives
void CPagetestReporting::CheckKeepAlive()
{
	keepAliveScore = -1;
	int count = 0;
	int total = 0;
	ATLTRACE(_T("[Pagetest] - CheckKeepAlive\n"));
	POSITION pos = events.GetHeadPosition();
	while( pos )
	{
		CTrackedEvent * e = events.GetNext(pos);
		if( e && e->type == CTrackedEvent::etWinInetRequest && !e->ignore )
		{
			CWinInetRequest * w = (CWinInetRequest *)e;
			if( w->result == 200 && w->fromNet )
			{
				w->keepAliveScore = 0;
				CString conn = w->response.connection;
				conn.MakeLower();
				if( conn.Find(_T("keep-alive")) > -1 &&
            conn.Find(_T("close")) == -1)
					w->keepAliveScore = 100;
				else
				{
					CString host = w->host;
					bool needed = false;
					bool reused = false;
					POSITION pos2 = events.GetHeadPosition();
					while( pos2 )
					{
						CTrackedEvent * e2 = events.GetNext(pos2);
						if( e2 && e != e2 && e2->type == CTrackedEvent::etWinInetRequest && !e2->ignore )
						{
							CWinInetRequest * w2 = (CWinInetRequest *)e2;
							if( !w2->host.CompareNoCase(host) )
							{
								needed = true;
								if( w2->socketId == w->socketId )
									reused = true;
							}
						}
					}
					if( reused )
						w->keepAliveScore = 100;
					else if( needed )
					{
						if( conn.Find(_T("close")) > -1 || w->response.ver < 1.1 )
							w->keepAliveScore = 0;
						else
							w->keepAliveScore = 100;
					}
					else
						w->keepAliveScore = -1;
				}
				if( !w->keepAliveScore )
					w->warning = true;
				if( w->keepAliveScore != -1 )
				{
					count++;
					total += w->keepAliveScore;
				}
			}
		}
	}
	if( count )
		keepAliveScore = total / count;
}
void CPagetestReporting :: CheckKeepAlive ( ) { keepAliveScore = -1 ; int count = 0 ; int total = 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 ; if ( w -> result == 200 && w -> fromNet ) { w -> keepAliveScore = 0 ; CString conn = w -> response . connection ; conn . MakeLower ( ) ; if ( conn . Find ( _T ( " " ) ) > -1 && conn . Find ( _T ( " " ) ) == -1 ) w -> keepAliveScore = 100 ; else { CString host = w -> host ; bool needed = false ; bool reused = false ; POSITION pos2 = events . GetHeadPosition ( ) ; while ( pos2 ) { CTrackedEvent * e2 = events . GetNext ( pos2 ) ; if ( e2 && e != e2 && e2 -> type == CTrackedEvent :: etWinInetRequest && ! e2 -> ignore ) { CWinInetRequest * w2 = ( CWinInetRequest * ) e2 ; if ( ! w2 -> host . CompareNoCase ( host ) ) { needed = true ; if ( w2 -> socketId == w -> socketId ) reused = true ; } } } if ( reused ) w -> keepAliveScore = 100 ; else if ( needed ) { if ( conn . Find ( _T ( " " ) ) > -1 || w -> response . ver < 1.1 ) w -> keepAliveScore = 0 ; else w -> keepAliveScore = 100 ; } else w -> keepAliveScore = -1 ; } if ( ! w -> keepAliveScore ) w -> warning = true ; if ( w -> keepAliveScore != -1 ) { count ++ ; total += w -> keepAliveScore ; } } } } if ( count ) keepAliveScore = total / count ; }
Make sure any host that served more than one asset used keep-alives
Make sure any host that served more than one asset used keep - alives
// see if there were any other requests from the same host
 // HTTP 1.1 defaults to keep-alive
 // average the keep alive scores of all of the objects for the page
