ripper234 / Whatever-Origin

An open source alternative to AnyOrigin.com (this project is looking for a maintainer)
http://whateverorigin.org/
320 stars 74 forks source link

Please support HEAD requests! #11

Open ytrezq opened 9 years ago

ytrezq commented 9 years ago

I need to get the file size of large videos, so I wrote this function :

function GetFileSize(Url){
  var size;
  var ajax = new XMLHttpRequest();
  ajax.onreadystatechange = function () {
    if (this.readyState == this.DONE) {
      size=ajax.getAllResponseHeaders();
      size=parseInt(ajax.getResponseHeader("Content-Length"));
    }
  };
  ajax.open('HEAD', Url, false); // <-- the 'false' makes it synchronous, and the 'HEAD' avoid to download the whole file
  ajax.send(null);
  return size/1048576;
}

which doesn't work, and it appear you don't supportHEADrequests :

HEAD /get?url=artestras.vo.llnwd.net/v2/am/HBBTV/048730-000-A_SQ_2_VF-STF_01483166_MP4-2200_AMM-HBBTV.mp4 HTTP/1.1
Host: www.whateverorigin.org
User-Agent: Mozilla/5.0 (compatible; MSIE 11.0; Windows NT 6.1; Win64; x64; Trident/7.0; .NET4.0C; .NET4.0E; InfoPath.3) Opera/12.50 Presto/2.12.378
Accept: text/html, application/xml;q=0.9, application/xhtml xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1
Accept-Language: en
Accept-Charset: iso-8859-1, utf-8, utf-16, *;q=0.1
Accept-Encoding: deflate, gzip, x-gzip, identity, *;q=0
Connection: Keep-Alive, TE
TE: deflate, gzip, chunked, identity, trailers

HTTP/1.1 500 Internal Server Error
Date: Sun, 05 Oct 2014 02:35:46 GMT
Connection: keep-alive
Server: Play! Framework;1.2.3;prod
Set-Cookie: PLAY_ERRORS=;Path=/
Content-Type: text/html; charset=utf-8
Content-Length: 417
Via: 1.1 vegur

The real site work as expected when it receive the request, but the brother reject the content (because of SOP):

HTTP/1.1 200 OK
Server: nginx/1.0.12
Content-Type: video/mp4
Accept-Ranges: bytes
X-Agile-Checksum: 5914f511b20f4e0563508cf629dfffa9bbe452ec7a64edd27cfb5a01622597ed
Age: 65997
Date: Sun, 05 Oct 2014 02:14:02 GMT
Last-Modified: Sun, 28 Sep 2014 19:42:44 GMT
Content-Length: 1577111989
Connection: keep-alive
ripper234 commented 9 years ago

pull requests welcome... (the project is not really maintained a.t.m).

ytrezq commented 9 years ago

Ok, but that was just to point this out, as there are already some alternatives.