agent/browser/ie/pagetest/PagetestReporting.cpp
/*-----------------------------------------------------------------------------
	Generate the detailled report for a single request
-----------------------------------------------------------------------------*/
Generate the detailled report for a single request
Generate the detailled report for a single request
void CPagetestReporting::SaveBodies(CString file)
{
  if (bodies || htmlbody)
  {
	  zipFile zip = zipOpen(CT2A(file), APPEND_STATUS_CREATE);
	  if( zip )
	  {
	    bool done = false;
	    DWORD count = 0;
      DWORD bodiesCount = 0;
	    POSITION pos = events.GetHeadPosition();
	    while( pos && !done )
	    {
		    CTrackedEvent * event = events.GetNext(pos);
		    if( event && event->type == CTrackedEvent::etWinInetRequest )
		    {
			    CWinInetRequest * r = (CWinInetRequest *)event;
			    CString mime = r->response.contentType;
			    mime.MakeLower();
          if( r->valid && r->fromNet )
          {
				    count++;
            if(r->result == 200 && r->body && r->bodyLen &&
               (mime.Find(_T("text/")) >= 0 || mime.Find(_T("javascript")) >= 0 || mime.Find(_T("json")) >= 0) )
			      {
              CStringA name;
              name.Format("%03d-response.txt", count);
						  if( !zipOpenNewFileInZip( zip, name, 0, 0, 0, 0, 0, 0, Z_DEFLATED, Z_BEST_COMPRESSION ) )
						  {
                zipWriteInFileInZip( zip, r->body, r->bodyLen );
							  zipCloseFileInZip( zip );
                bodiesCount++;
                if (htmlbody)
                  done = true;
						  }
            }
          }
		    }
	    }
		  zipClose(zip, 0);
      if(!bodiesCount)
        DeleteFile(file);
    }
  }
}
void CPagetestReporting :: SaveBodies ( CString file ) { if ( bodies || htmlbody ) { zipFile zip = zipOpen ( CT2A ( file ) , APPEND_STATUS_CREATE ) ; if ( zip ) { bool done = false ; DWORD count = 0 ; DWORD bodiesCount = 0 ; POSITION pos = events . GetHeadPosition ( ) ; while ( pos && ! done ) { CTrackedEvent * event = events . GetNext ( pos ) ; if ( event && event -> type == CTrackedEvent :: etWinInetRequest ) { CWinInetRequest * r = ( CWinInetRequest * ) event ; CString mime = r -> response . contentType ; mime . MakeLower ( ) ; if ( r -> valid && r -> fromNet ) { count ++ ; if ( r -> result == 200 && r -> body && r -> bodyLen && ( mime . Find ( _T ( " " ) ) >= 0 || mime . Find ( _T ( " " ) ) >= 0 || mime . Find ( _T ( " " ) ) >= 0 ) ) { CStringA name ; name . Format ( " " , count ) ; if ( ! zipOpenNewFileInZip ( zip , name , 0 , 0 , 0 , 0 , 0 , 0 , Z_DEFLATED , Z_BEST_COMPRESSION ) ) { zipWriteInFileInZip ( zip , r -> body , r -> bodyLen ) ; zipCloseFileInZip ( zip ) ; bodiesCount ++ ; if ( htmlbody ) done = true ; } } } } } zipClose ( zip , 0 ) ; if ( ! bodiesCount ) DeleteFile ( file ) ; } } }
Generate the detailled report for a single request
Generate the detailled report for a single request
// add the file to the archive
 // write the file to the archive
