agent/browser/ie/pagetest/PagetestReporting.cpp
// We attempt to approximate the HTTP date of the response
// by looking at the last sync time of the cache entry. This should be a
// reasonable approximation of the HTTP date in cases where the response was 
// served from the origin server, but not necessarily in cases where the 
// response was served by an intermediate proxy that preserved the original 
// Date header. Still, this is better than using the current time.

We attempt to approximate the HTTP date of the response
by looking at the last sync time of the cache entry. This should be a
reasonable approximation of the HTTP date in cases where the response was
served from the origin server, but not necessarily in cases where the
response was served by an intermediate proxy that preserved the original
Date header. Still, this is better than using the current time.
We attempt to approximate the HTTP date of the response by looking at the last sync time of the cache entry . This should be a reasonable approximation of the HTTP date in cases where the response was served from the origin server but not necessarily in cases where the response was served by an intermediate proxy that preserved the original Date header . Still this is better than using the current time .
CString SynthesizeDateHeaderForResource(const CString& url)
{
	CString retVal;
	CString obUrlNoFragment = url;
	int fragmentIndex = obUrlNoFragment.Find('#');
	if (fragmentIndex > 0)
	{
		obUrlNoFragment = obUrlNoFragment.Left(fragmentIndex);
	}
	LPINTERNET_CACHE_ENTRY_INFO info = NULL;
	DWORD infoLen = 0;
	if (!GetUrlCacheEntryInfo(obUrlNoFragment, info, &infoLen))
	{
		if (ERROR_INSUFFICIENT_BUFFER == GetLastError()) 
		{
			info = static_cast<LPINTERNET_CACHE_ENTRY_INFO>(malloc(infoLen));
			memset(info, 0, infoLen);
			if (GetUrlCacheEntryInfo(obUrlNoFragment, info, &infoLen))
			{
				SYSTEMTIME lastSyncSystemTime;
				if (FileTimeToSystemTime(&info->LastSyncTime, &lastSyncSystemTime))
				{
					const DWORD bufSize = (INTERNET_RFC1123_BUFSIZE + 1) * sizeof(TCHAR);
					TCHAR* buf = static_cast<TCHAR*>(malloc(bufSize));
					memset(buf, 0, bufSize);
					retVal;
					if (InternetTimeFromSystemTime(&lastSyncSystemTime, INTERNET_RFC1123_FORMAT, buf, bufSize))
					{
						retVal = buf;
					}
					free(buf);
				}
			}
			free(info);
		}
	}
	return retVal;
}
CString SynthesizeDateHeaderForResource ( const CString & url ) { CString retVal ; CString obUrlNoFragment = url ; int fragmentIndex = obUrlNoFragment . Find ( ' ' ) ; if ( fragmentIndex > 0 ) { obUrlNoFragment = obUrlNoFragment . Left ( fragmentIndex ) ; } LPINTERNET_CACHE_ENTRY_INFO info = NULL ; DWORD infoLen = 0 ; if ( ! GetUrlCacheEntryInfo ( obUrlNoFragment , info , & infoLen ) ) { if ( ERROR_INSUFFICIENT_BUFFER == GetLastError ( ) ) { info = static_cast < LPINTERNET_CACHE_ENTRY_INFO > ( malloc ( infoLen ) ) ; memset ( info , 0 , infoLen ) ; if ( GetUrlCacheEntryInfo ( obUrlNoFragment , info , & infoLen ) ) { SYSTEMTIME lastSyncSystemTime ; if ( FileTimeToSystemTime ( & info -> LastSyncTime , & lastSyncSystemTime ) ) { const DWORD bufSize = ( INTERNET_RFC1123_BUFSIZE + 1 ) * sizeof ( TCHAR ) ; TCHAR * buf = static_cast < TCHAR * > ( malloc ( bufSize ) ) ; memset ( buf , 0 , bufSize ) ; retVal ; if ( InternetTimeFromSystemTime ( & lastSyncSystemTime , INTERNET_RFC1123_FORMAT , buf , bufSize ) ) { retVal = buf ; } free ( buf ) ; } } free ( info ) ; } } return retVal ; }
We attempt to approximate the HTTP date of the response
by looking at the last sync time of the cache entry.
We attempt to approximate the HTTP date of the response by looking at the last sync time of the cache entry .
// Remove the fragment from the URL, if any. GetUrlCacheEntryInfo does not
 // remove fragments on its own, and will fail if they are present.
 // Call GetUrlCacheEntryInfo with a zero-length buffer. We expect it to fail
 // with ERROR_INSUFFICIENT_BUFFER, but this lets us discover the required
 // buffer size so we can allocate a buffer and call it again.
 // Need to reserve the buffer size + 1 (for NULL character).
