agent/browser/ie/pagetest/PagetestReporting.cpp
/*-----------------------------------------------------------------------------
	See if the provided host belongs to a CDN
-----------------------------------------------------------------------------*/
See if the provided host belongs to a CDN
See if the provided host belongs to a CDN
bool CPagetestReporting::IsCDN(CWinInetRequest * w, CString &provider)
{
	bool ret = false;
	CString host = w->host;
	host.MakeLower();
  provider.Empty();
	if( !host.IsEmpty() )
	{
		bool found = false;
		EnterCriticalSection(&csCDN);
		POSITION pos = cdnLookups.GetHeadPosition();
		while( pos && !found )
		{
			CCDNEntry &entry = cdnLookups.GetNext(pos);
			if( entry.name == host )
			{
				found = true;
				ret = entry.isCDN;
				provider = entry.provider;
			}
		}
		LeaveCriticalSection(&csCDN);
		if( !found ) {
      int cdn_header_count = _countof(cdnHeaderList);
      for (int i = 0; i < cdn_header_count && !found; i++) {
        CDN_PROVIDER_HEADER * cdn_header = &cdnHeaderList[i];
        CString header = w->GetResponseHeader((LPCTSTR)CA2T(cdn_header->response_field));
        header.MakeLower();
        CString pattern = CA2T(cdn_header->pattern);
        pattern.MakeLower();
        if (header.GetLength() &&
            (!pattern.GetLength() ||
             header.Find(pattern) >= 0)) {
            found = true;
            ret = true;
            provider = cdn_header->name;
        }
      }
		}
	}
  if (ret && w->basePage) {
    basePageCDN = w->cdnProvider;
  }
	return ret;
}
bool CPagetestReporting :: IsCDN ( CWinInetRequest * w , CString & provider ) { bool ret = false ; CString host = w -> host ; host . MakeLower ( ) ; provider . Empty ( ) ; if ( ! host . IsEmpty ( ) ) { bool found = false ; EnterCriticalSection ( & csCDN ) ; POSITION pos = cdnLookups . GetHeadPosition ( ) ; while ( pos && ! found ) { CCDNEntry & entry = cdnLookups . GetNext ( pos ) ; if ( entry . name == host ) { found = true ; ret = entry . isCDN ; provider = entry . provider ; } } LeaveCriticalSection ( & csCDN ) ; if ( ! found ) { int cdn_header_count = _countof ( cdnHeaderList ) ; for ( int i = 0 ; i < cdn_header_count && ! found ; i ++ ) { CDN_PROVIDER_HEADER * cdn_header = & cdnHeaderList [ i ] ; CString header = w -> GetResponseHeader ( ( LPCTSTR ) CA2T ( cdn_header -> response_field ) ) ; header . MakeLower ( ) ; CString pattern = CA2T ( cdn_header -> pattern ) ; pattern . MakeLower ( ) ; if ( header . GetLength ( ) && ( ! pattern . GetLength ( ) || header . Find ( pattern ) >= 0 ) ) { found = true ; ret = true ; provider = cdn_header -> name ; } } } } if ( ret && w -> basePage ) { basePageCDN = w -> cdnProvider ; } return ret ; }
See if the provided host belongs to a CDN
See if the provided host belongs to a CDN
// See if the host name or any CNAMEs were known CDN's
 // these would have been added directly at the time of
 // the DNS lookup
 // now check http headers for known CDNs
