Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save fischman/2879255 to your computer and use it in GitHub Desktop.
Save fischman/2879255 to your computer and use it in GitHub Desktop.
attempt at testing <video> CORS support
GET /security/resources/video-cross-origin-allow.php?name=../../media/resources/test.mp4&type=video/mp4 HTTP/1.1
Host: localhost:8080
Connection: keep-alive
Origin: http://127.0.0.1:8000
Accept-Encoding: identity;q=1, *;q=0
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1165.0 Safari/537.1
Accept: */*
Referer: http://127.0.0.1:8000/security/video-cross-origin-readback.html
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
Range: bytes=0-192843
If-None-Match: "192844-1309378694"
If-Modified-Since: Wed, 06 Jun 2012 01:09:16 GMT
HTTP/1.1 200 OK
X-Powered-By: PHP/5.3.2-1ubuntu4.15
Access-Control-Allow-Origin: *
Access-Control-Max-Age: 3628800
Status: HTTP/1.1 206 Partial Content
Last-Modified: Wed, 06 Jun 2012 01:10:29 GMT
Pragma: no-cache
Etag: "192844-1309378694"
Content-Type: video/mp4
Accept-Ranges: bytes
Content-Range: bytes 0-192843/192844
Connection: close
Transfer-Encoding: chunked
Date: Wed, 06 Jun 2012 01:10:29 GMT
Server: LightTPD/1.4.19 (Win32)
<?php
header("Access-Control-Allow-Origin: *");
if ($_SERVER['REQUEST_METHOD'] == "OPTIONS") {
header("Access-Control-Allow-Methods: GET");
header("Access-Control-Allow-Headers: origin, accept-encoding, referer, range");
exit;
}
@include("../../media/resources/serve-video.php");
?>
<html>
<body onload="start()">
<script src=../../media-resources/video-test.js></script>
<script src=../../media-resources/media-file.js></script>
<script>
var animationFrameCount = 0;
var gl, t;
waitForEvent('error', function() {
failTest("error: " + JSON.stringify(video.error));
});
function updateTexture() {
if (animationFrameCount > 10)
endTest();
window.webkitRequestAnimationFrame(updateTexture);
if (video.readyState < video.HAVE_FUTURE_DATA)
return;
gl.bindTexture(gl.TEXTURE_2D, t);
try {
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, video);
} catch (e) {
failTest("Caught error: " + e);
}
gl.bindTexture(gl.TEXTURE_2D, null);
++animationFrameCount;
}
function start() {
findMediaElement();
var mediaFile = findMediaFile("video", "../../media/resources/test");
var type = mimeTypeForExtension(mediaFile.split('.').pop());
video.src = "http://localhost:8080/security/resources/video-cross-origin-allow.php?name=" + mediaFile + "&type=" + type;
video.play();
gl = document.getElementsByTagName('canvas')[0].getContext('experimental-webgl');
t = gl.createTexture();
updateTexture();
}
</script>
<video crossorigin style="display: none;"></video>
<canvas></canvas>
</body>
</head>
OPTIONS /security/resources/video-cross-origin-allow.php?name=../../media/resources/test.mp4&type=video/mp4 HTTP/1.1
Host: localhost:8080
Connection: keep-alive
Access-Control-Request-Method: GET
Origin: http://127.0.0.1:8000
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1165.0 Safari/537.1
Access-Control-Request-Headers: origin, accept-encoding, referer, range
Accept: */*
Referer: http://127.0.0.1:8000/security/video-cross-origin-readback.html
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
HTTP/1.1 200 OK
X-Powered-By: PHP/5.3.2-1ubuntu4.15
Access-Control-Allow-Origin: *
Access-Control-Max-Age: 3628800
Access-Control-Allow-Methods: GET
Access-Control-Allow-Headers: origin, accept-encoding, referer, range
Content-type: text/html
Transfer-Encoding: chunked
Date: Wed, 06 Jun 2012 01:10:29 GMT
Server: LightTPD/1.4.19 (Win32)
OPTIONS /security/resources/video-cross-origin-allow.php?name=../../media/resources/test.mp4&type=video/mp4 HTTP/1.1
Host: localhost:8080
Connection: keep-alive
Access-Control-Request-Method: GET
Origin: http://127.0.0.1:8000
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1165.0 Safari/537.1
Access-Control-Request-Headers: origin, accept-encoding, referer, range
Accept: */*
Referer: http://127.0.0.1:8000/security/video-cross-origin-readback.html
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
HTTP/1.1 200 OK
X-Powered-By: PHP/5.3.2-1ubuntu4.15
Access-Control-Allow-Origin: *
Access-Control-Max-Age: 3628800
Access-Control-Allow-Methods: GET
Access-Control-Allow-Headers: origin, accept-encoding, referer, range
Content-type: text/html
Transfer-Encoding: chunked
Date: Wed, 06 Jun 2012 01:10:29 GMT
Server: LightTPD/1.4.19 (Win32)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment