Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / navigation / resources / check-beacon.php
blob9b42b96672311573eb3e85c40ae336a42c145479
1 <?php
2 require_once '../../resources/portabilityLayer.php';
4 $beaconFilename = sys_get_temp_dir() . "/beacon" . (isset($_REQUEST['name']) ? $_REQUEST['name'] : "") . ".txt";
6 $max_attempts = 700;
7 $retries = isset($_REQUEST['retries']) ? (int)$_REQUEST['retries'] : $max_attempts;
8 while (!file_exists($beaconFilename) && $retries != 0) {
9 usleep(10000);
10 # file_exists() caches results, we want to invalidate the cache.
11 clearstatcache();
12 $retries--;
15 header('Content-Type: text/plain');
16 header('Access-Control-Allow-Origin: *');
17 if (file_exists($beaconFilename)) {
18 $beaconFile = false;
19 if (is_readable($beaconFilename)) {
20 $beaconFile = fopen($beaconFilename, 'r');
22 if ($beaconFile) {
23 echo "Beacon sent successfully\n";
24 while ($line = fgets($beaconFile)) {
25 $trimmed = trim($line);
26 if ($trimmed != "")
27 echo "$trimmed\n";
29 fclose($beaconFile);
30 unlink($beaconFilename);
31 } else {
32 echo "Beacon status not readable\n";
34 } else {
35 echo "Beacon not sent\n";