Last modified: 2014-10-20 17:41:57 UTC
I'm doing some experiments with client-side video manipulation and need to be able to load up a subset of a file via XMLHttpRequest to implement streaming and seeking. In theory I can do this by adding a 'Range' header with a byte range: xhr.setRequestHeader("range", "bytes=" + position + "-" + endPosition); However for a cross-domain request this triggers a 'preflight' OPTIONS request to ask the server if it's ok to send 'Range' headers -- that OPTIONS hit includes this request header: Access-Control-Allow-Headers: Range the OPTIONS *response* needs to include the same line back to us, or the browser will refuse to make an actual GET request including the 'Range' header. Without the Range header this leaves me only able to fetch the entire file into memory at once, which won't be suitable for large video files.
Change 89238 had a related patch set uploaded by Aaron Schulz: Add Range header support to CORS headers https://gerrit.wikimedia.org/r/89238
Change 89238 abandoned by Aaron Schulz: Add Range header support to CORS headers Reason: Yeah, not worth it https://gerrit.wikimedia.org/r/89238
Note that I've found some workarounds for streaming video manipulation which make that project less dependent on needing Range requests[1]. I'd still want it to support seeking into a part of the file that's not yet been buffered, but basic progressive download is working without it. [1] https://github.com/brion/ogv.js/blob/master/src/StreamFile.js
Did that Swift upgrade mentioned last year on the abandoned patch ever go through? I'm getting pretty close to ready to land ogv.js playback (bug 61823), but CORS Range header support would help with a couple things that irk me: 1) Allow discarding already-played data from memory in Safari! 2) Allow seeking to arbitrary positions in the file. If this is easier to do correctly now, would love to poke at it.
Change 167542 had a related patch set uploaded by Faidon Liambotis: Handle CORS preflight requests for upload in VCL https://gerrit.wikimedia.org/r/167542
Change 167542 merged by Faidon Liambotis: Handle CORS preflight requests for upload in VCL https://gerrit.wikimedia.org/r/167542
Confirmed working with XHR in Safari 8 and IE 11. Woohoooooooo! Thanks guys!