Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/perl -wT | |
| 2 | |
| 3 use strict; | |
| 4 | |
| 5 use CGI; | |
| 6 use File::stat; | |
| 7 | |
| 8 my $query = new CGI; | |
| 9 | |
| 10 my $name = $query->param('name'); | |
| 11 my $filesize = stat($name)->size; | |
| 12 | |
| 13 # Get MIME type if provided. Default to video/mp4. | |
| 14 my $type = $query->param('type') || "video/mp4"; | |
|
acolwell GONE FROM CHROMIUM
2014/06/18 23:46:27
nit: Please remove the default so this parameter m
Srirama
2014/06/19 03:35:15
I will remove the default parameter. But I feel we
acolwell GONE FROM CHROMIUM
2014/06/23 16:35:28
But returning 400 will likely cause a test to fail
Srirama
2014/06/24 05:23:01
Done.
| |
| 15 | |
| 16 my $rangeEnd = $filesize - 1; | |
| 17 | |
| 18 # Print HTTP Header, disabling cache. | |
| 19 print "Cache-Control: no-cache\n"; | |
|
acolwell GONE FROM CHROMIUM
2014/06/18 23:46:27
What is responsible for printing the HTTP status l
Srirama
2014/06/19 03:35:15
I think based on the CGI output apache server will
| |
| 20 print "Content-Length: " . $filesize . "\n"; | |
| 21 print "Content-Type: " . $type . "\n"; | |
| 22 | |
| 23 print "\n"; | |
| 24 | |
| 25 open FILE, $name or die; | |
| 26 binmode FILE; | |
| 27 my ($data, $n); | |
| 28 my $total = 0; | |
| 29 my $break = $filesize / 4; | |
| 30 my $string = "corrupt video"; | |
| 31 seek(FILE, 0, 0); | |
| 32 | |
| 33 while (($n = read FILE, $data, 1024) != 0) { | |
| 34 print $data; | |
| 35 | |
| 36 $total += $n; | |
| 37 if ($total >= $filesize) { | |
| 38 last; | |
| 39 } | |
| 40 | |
| 41 if ($total >= $break) { | |
| 42 print $string; | |
| 43 $total += length($string); | |
| 44 } | |
| 45 | |
| 46 } | |
| 47 close(FILE); | |
| OLD | NEW |