예제 #1
0
         if ($testlen < $strlen && substr_compare($filename, $test, -$testlen) === 0) {
             $pcapfile = $filename;
             break;
         }
     }
 } else {
     move_uploaded_file($_FILES['file']['tmp_name'], $pcapfile);
 }
 // Execute pcap2har
 $harfile = $pcapfile . ".har";
 $useLatestPCap2Har = ShouldUseLatestPcap2Har();
 $suppressPageRecords = false;
 // Mobitest agent needs page records.
 $consoleOut = array();
 $returnCode = 0;
 ExecPcap2Har($pcapfile, $harfile, $useLatestPCap2Har, $suppressPageRecords, $consoleOut);
 $harText = null;
 if (file_exists($harfile)) {
     $harText = file_get_contents($harfile);
 }
 if ($returnCode == 0) {
     header("HTTP/1.0 200 Ok");
     header('Content-type: application/json');
     header("Cache-Control: no-cache, must-revalidate");
     header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
     echo $harText;
     rrmdir($pcappath);
 } else {
     header("HTTP/1.0 400 Bad Request");
     header('Content-type: text/plain');
     header("Cache-Control: no-cache, must-revalidate");
예제 #2
0
 public function TestGoogleDotComPCapFromDevice()
 {
     $consoleOut = array();
     $harFile = TMP . "/googleDotComFromDevice.har";
     $returnCode = ExecPcap2Har("unittests/data/googleDotComFromEmulator.pcap", $harFile, USE_LATEST_PCAP2HAR, SUPPRESS_PAGE_RECORDS, $consoleOut);
     \Enhance\Assert::areIdentical(print_r(array(), true), print_r($consoleOut, true));
     \Enhance\Assert::areIdentical(0, $returnCode);
     $harAsString = file_get_contents($harFile);
     $harAsPhpDict = json_decode($harAsString, true);
     \Enhance\Assert::isNotNull($harAsPhpDict);
     // Failed to parse as JSON
     // Test a few properties of the HAR, to see that it is well formed.
     \Enhance\Assert::areIdentical("1.1", $harAsPhpDict['log']['version']);
     // Older version of pcap2har see fewer requests, because packets arrive
     // out of the expected order.
     \Enhance\Assert::areIdentical(11, count($harAsPhpDict['log']['entries']));
 }