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

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

Issue 1356353003: Relax cross-origin partial response requirements for CORS presence. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert accidental php change. Created 5 years, 1 month 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) && empty($_GET["norange"])) { 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("Content-Length: " . ($end - $start) + 1); 25 header("Content-Length: " . ($end - $start) + 1);
26 if ($contentRange && empty($_GET["norange"])) { 26 if ($contentRange && empty($_GET["norange"])) {
27 header("Accept-Ranges: bytes"); 27 header("Accept-Ranges: bytes");
28 header("Content-Range: bytes " . $start . "-" . $end . "/" . $fileSize); 28 header("Content-Range: bytes " . $start . "-" . $end . "/" . $fileSize);
29 } 29 }
30 if (isset($_GET['cors_allow_origin'])) {
31 header("Access-Control-Allow-Origin: " . $_GET['cors_allow_origin']);
32 }
30 header("Connection: close"); 33 header("Connection: close");
31 34
32 $chunkSize = 1024 * 256; 35 $chunkSize = 1024 * 256;
33 $offset = $start; 36 $offset = $start;
34 37
35 $fn = fopen($fileName, "rb"); 38 $fn = fopen($fileName, "rb");
36 fseek($fn, $offset, 0); 39 fseek($fn, $offset, 0);
37 40
38 while (!feof($fn) && $offset <= $end && connection_status() == 0) { 41 while (!feof($fn) && $offset <= $end && connection_status() == 0) {
39 $readSize = min($chunkSize, ($end - $offset) + 1); 42 $readSize = min($chunkSize, ($end - $offset) + 1);
40 $buffer = fread($fn, $readSize); 43 $buffer = fread($fn, $readSize);
41 print($buffer); 44 print($buffer);
42 flush(); 45 flush();
43 $offset += $chunkSize; 46 $offset += $chunkSize;
44 } 47 }
45 fclose($fn); 48 fclose($fn);
46 49
47 exit; 50 exit;
48 ?> 51 ?>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698