| OLD | NEW |
| (Empty) |
| 1 #!/usr/bin/perl -wT | |
| 2 | |
| 3 use CGI; | |
| 4 use File::stat; | |
| 5 use Time::HiRes; | |
| 6 | |
| 7 $query = new CGI; | |
| 8 $name = $query->param('name'); | |
| 9 $stallAt = $query->param('stallAt'); | |
| 10 $stallFor = $query->param('stallFor'); | |
| 11 $mimeType = $query->param('mimeType'); | |
| 12 | |
| 13 my $filesize = stat($name)->size; | |
| 14 print "Content-type: " . $mimeType . "\n"; | |
| 15 print "Content-Length: " . $filesize . "\n\n"; | |
| 16 | |
| 17 open FILE, $name or die; | |
| 18 binmode FILE; | |
| 19 $total = 0; | |
| 20 my ($buf, $data, $n); | |
| 21 while (($n = read FILE, $data, 1024) != 0) { | |
| 22 $total += $n; | |
| 23 if ($total > $stallAt) { | |
| 24 if (defined $stallFor) { | |
| 25 Time::HiRes::sleep($stallFor) | |
| 26 } | |
| 27 last; | |
| 28 } | |
| 29 print $data; | |
| 30 } | |
| 31 close(FILE); | |
| OLD | NEW |