Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(284)

Side by Side Diff: LayoutTests/http/tests/resources/load-and-stall.php

Issue 14246006: Implementing timeout support for XHR (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@timeoutResourceHandle
Patch Set: Timeout support in DocumentThreadableLoader (speculative bot failure fix) Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <?php 1 <?php
2 $name = $_GET['name']; 2 $name = $_GET['name'];
3 $stallAt = $_GET['stallAt']; 3 $stallAt = $_GET['stallAt'];
4 $stallFor = $_GET['stallFor']; 4 $stallFor = $_GET['stallFor'];
5 $mimeType = $_GET['mimeType']; 5 $mimeType = $_GET['mimeType'];
6 6
7 $file = fopen($name, "rb"); 7 $file = fopen($name, "rb");
8 if (!$file) 8 if (!$file)
9 die("Cannot open file."); 9 die("Cannot open file.");
10 10
11 header("Content-Type: " . $mimeType); 11 header("Content-Type: " . $mimeType);
12 header("Content-Length: " . filesize($name)); 12 header("Content-Length: " . filesize($name));
13 13
14 if (isset($stallAt) && isset($stallFor)) { 14 if (isset($stallAt) && isset($stallFor)) {
15 $stallAt = (int)$stallAt; 15 $stallAt = (int)$stallAt;
16 $stallFor = (int)$stallFor;
17 if ($stallAt > filesize($name)) 16 if ($stallAt > filesize($name))
18 die("Incorrect value for stallAt."); 17 die("Incorrect value for stallAt.");
19 $written = 0; 18 $written = 0;
20 while ($written < $stallAt) { 19 while ($written < $stallAt) {
21 $write = 1024; 20 $write = 1024;
22 if ($write > $stallAt - $written) 21 if ($write > $stallAt - $written)
23 $write = $stallAt - $written; 22 $write = $stallAt - $written;
24 23
25 echo(fread($file, $write)); 24 echo(fread($file, $write));
26 $written += $write; 25 $written += $write;
27 flush(); 26 flush();
28 ob_flush(); 27 ob_flush();
29 } 28 }
30 usleep($stallFor * 1000000); 29 usleep($stallFor * 1000000);
31 echo(fread($file, filesize($name) - $stallAt)); 30 echo(fread($file, filesize($name) - $stallAt));
32 } else { 31 } else {
33 echo(fread($file, filesize($name))); 32 echo(fread($file, filesize($name)));
34 } 33 }
35 flush(); 34 flush();
36 ob_flush(); 35 ob_flush();
37 fclose($file); 36 fclose($file);
38 ?> 37 ?>
OLDNEW
« no previous file with comments | « LayoutTests/TestExpectations ('k') | LayoutTests/http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698