Page MenuHomePhabricator

upload.wikimedia.org should allow 'Range' via Access-Control-Allow-Headers on CORS preflight
Closed, ResolvedPublic

Description

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.


Version: wmf-deployment
Severity: normal

Details

Reference
bz55631

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 2:28 AM
bzimport set Reference to bz55631.
bzimport added a subscriber: Unknown Object (MLST).

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!
  1. 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!

Gilles raised the priority of this task from Medium to Unbreak Now!.Dec 4 2014, 10:11 AM
Gilles moved this task from Untriaged to Done on the Multimedia board.
Gilles lowered the priority of this task from Unbreak Now! to Medium.Dec 4 2014, 11:23 AM