Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please support HEAD requests! #11

Open
ytrezq opened this issue Oct 5, 2014 · 2 comments
Open

Please support HEAD requests! #11

ytrezq opened this issue Oct 5, 2014 · 2 comments

Comments

@ytrezq
Copy link

ytrezq commented Oct 5, 2014

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
Copy link
Owner

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

@ytrezq
Copy link
Author

ytrezq commented Oct 5, 2014

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants