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

Side by Side Diff: LayoutTests/http/tests/media/resources/serve-video.php

Issue 562493003: Allow seeks to zero on streaming sources. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add tests. Created 6 years, 3 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 2
3 $fileName = $_GET["name"]; 3 $fileName = $_GET["name"];
4 $type = $_GET["type"]; 4 $type = $_GET["type"];
5 5
6 $fileSize = filesize($fileName); 6 $fileSize = filesize($fileName);
7 $start = 0; 7 $start = 0;
8 $end = $fileSize - 1; 8 $end = $fileSize - 1;
9 $contentRange = $_SERVER["HTTP_RANGE"]; 9 $contentRange = $_SERVER["HTTP_RANGE"];
10 if (isset($contentRange)) { 10 if (isset($contentRange) && empty($_GET["norange"])) {
11 $range = explode("-", substr($contentRange, strlen("bytes="))); 11 $range = explode("-", substr($contentRange, strlen("bytes=")));
12 $start = intval($range[0]); 12 $start = intval($range[0]);
13 if (!empty($range[1])) 13 if (!empty($range[1]))
14 $end = intval($range[1]); 14 $end = intval($range[1]);
15 $httpStatus = "206 Partial Content"; 15 $httpStatus = "206 Partial Content";
16 } else 16 } else
17 $httpStatus = "200 OK"; 17 $httpStatus = "200 OK";
18 18
19 header("Status: " . $httpStatus); 19 header("Status: " . $httpStatus);
20 header("HTTP/1.1 " . $httpStatus); 20 header("HTTP/1.1 " . $httpStatus);
21 header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); 21 header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
22 header("Pragma: no-cache"); 22 header("Pragma: no-cache");
23 header("Etag: " . '"' . $fileSize . "-" . filemtime($fileName) . '"'); 23 header("Etag: " . '"' . $fileSize . "-" . filemtime($fileName) . '"');
24 header("Content-Type: " . $type); 24 header("Content-Type: " . $type);
25 header("Accept-Ranges: bytes");
26 header("Content-Length: " . ($end - $start) + 1); 25 header("Content-Length: " . ($end - $start) + 1);
27 if ($contentRange) 26 if ($contentRange && empty($_GET["norange"])) {
28 » » header("Content-Range: bytes " . $start . "-" . $end . "/" . $fi leSize); 27 header("Accept-Ranges: bytes");
28 » » header("Content-Range: bytes " . $start . "-" . $end . "/" . $fi leSize);
29 }
29 header("Connection: close"); 30 header("Connection: close");
30 31
31 $chunkSize = 1024 * 256; 32 $chunkSize = 1024 * 256;
32 $offset = $start; 33 $offset = $start;
33 34
34 $fn = fopen($fileName, "rb"); 35 $fn = fopen($fileName, "rb");
35 fseek($fn, $offset, 0); 36 fseek($fn, $offset, 0);
36 37
37 while (!feof($fn) && $offset <= $end && connection_status() == 0) { 38 while (!feof($fn) && $offset <= $end && connection_status() == 0) {
38 $readSize = min($chunkSize, ($end - $offset) + 1); 39 $readSize = min($chunkSize, ($end - $offset) + 1);
39 $buffer = fread($fn, $readSize); 40 $buffer = fread($fn, $readSize);
40 print($buffer); 41 print($buffer);
41 flush(); 42 flush();
42 $offset += $chunkSize; 43 $offset += $chunkSize;
43 } 44 }
44 fclose($fn); 45 fclose($fn);
45 46
46 exit; 47 exit;
47 ?> 48 ?>
OLDNEW
« no previous file with comments | « LayoutTests/http/tests/media/resources/load-video.php ('k') | Source/core/html/HTMLMediaElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698