forked from catchpoint/WebPageTest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
getTimeline.php
39 lines (39 loc) · 1.39 KB
/
getTimeline.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
include 'common.inc';
$ok = false;
if (gz_is_file("$testPath/$run{$cachedText}_timeline.json")) {
$ok = true;
header("Content-disposition: attachment; filename=timeline.json");
header ("Content-type: application/json");
gz_readfile_chunked("$testPath/$run{$cachedText}_timeline.json");
} elseif (gz_is_file("$testPath/$run{$cachedText}_devtools.json")) {
$devTools = json_decode(gz_file_get_contents("$testPath/$run{$cachedText}_devtools.json"), true);
if (isset($devTools) && is_array($devTools) && count($devTools)) {
$timeline = array();
foreach ($devTools as &$entry) {
if (isset($entry) &&
is_array($entry) &&
array_key_exists('method', $entry) &&
$entry['method'] == 'Timeline.eventRecorded' &&
array_key_exists('params', $entry) &&
is_array($entry['params']) &&
array_key_exists('record', $entry['params']) &&
is_array($entry['params']['record']) &&
count($entry['params']['record'])) {
if (!$ok) {
$ok = true;
header("Content-disposition: attachment; filename=timeline.json");
header ("Content-type: application/json");
echo '[';
} else
echo ',';
echo json_encode($entry['params']['record']);
}
}
if ($ok)
echo ']';
}
}
if (!$ok)
header("HTTP/1.0 404 Not Found");
?>