Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / resources / load-and-stall.php
blob53427f236a9834e60558e1956234f887dd312241
1 <?php
2 $name = $_GET['name'];
3 $stallAt = $_GET['stallAt'];
4 $stallFor = $_GET['stallFor'];
5 $mimeType = $_GET['mimeType'];
7 $file = fopen($name, "rb");
8 if (!$file)
9 die("Cannot open file.");
11 header("Content-Type: " . $mimeType);
12 header("Content-Length: " . filesize($name));
14 if (isset($stallAt) && isset($stallFor)) {
15 $stallAt = (int)$stallAt;
16 if ($stallAt > filesize($name))
17 die("Incorrect value for stallAt.");
18 $written = 0;
19 while ($written < $stallAt) {
20 $write = 1024;
21 if ($write > $stallAt - $written)
22 $write = $stallAt - $written;
24 echo(fread($file, $write));
25 $written += $write;
26 flush();
27 ob_flush();
29 usleep($stallFor * 1000000);
30 echo(fread($file, filesize($name) - $stallAt));
31 } else {
32 echo(fread($file, filesize($name)));
34 flush();
35 ob_flush();
36 fclose($file);