Hello,
This is a long question, and it doesn't have anything to do with C++. I've decided to post this in the lounge since the other boards aren't appropriate, and I didn't feel like finding a more niche forum. I know this forum is pretty busy and there are a lot of folks here that specialize in several domains.
I have to preface my question by saying that, recently, I've been trying to download some .mp4's being streamed by a
JWPlayer on some website. This is pretty easy to do - in Chrome's dev console you can log requests to media resources and find the direct URL to a resource and simply download it from there - which is what I've been doing with much success.
There is, however, one video which I cannot access. The
JWPlayer will display the video with no problems, but when I attempt to access the video resource directly Chrome returns an error, namely:
ERR_CONTENT_LENGTH_MISTMATCH. I'm aware that this error is a result of the request and response headers'
Content-Length attributes not matching up (The server is misconfigured, and reports a
Content-Length that is completely divorced from reality - i.e. the file sizes differ).
I also noticed that my version of Internet Explorer will open the video resource in Windows Media Player by default. It won't try to download it, or even let me. The video will stream in Windows Media Player with out any problems, but I still won't be able to download it.
I've tried several different options to circumvent this problem. I've tried downloading and installing different versions of different browsers which apparently "ignore" the
Content-Length attribute of these HTTP headers and will display resources with mismatched lengths according to this archived blog post:
http://blogs.msdn.com/b/ieinternals/archive/2011/03/09/browsers-accommodate-incorrect-http-content-length-and-sites-depressingly-depend-on-it.aspx
Which didn't work.
I've also tried capturing the stream in VLC player - didn't work.
I've tried tampering with my default applications, to see if I could force certain browsers to stream and others to download - didn't work.
I wrote a program in C++ using libCurl to try and download the resource. I set libCurl to be as verbose as possible, so here are the details from one request to access the resource:
HTTP/1.1 200 OK
Date: REDACTED
Server: REDACTED
X-Powered-By: PHP/5.4.45
Set-Cookie: REDACTED
Expires: REDACTED
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Accept-Ranges: bytes
Content-Length: 273628708
Content-Type: video/mp4
X-Varnish: 33423606
Age: 0
Via: 1.1 varnish-v4
Connection: keep-alive
Accept-Ranges: bytes
transfer closed with 273628708 bytes remaining to read |
Note the error. The connection was terminated, and not even a single byte of data had been transferred. I then proceeded to enable different options such as changing
CURLOPT_HTTP_VERSION to
CURL_HTTP_VERSION_1_0 (I read somewhere that certain versions of the protocol handle these header attributes differently, or ignore them entirely). I also tried to setting chunked Transfer-Encoding, as well as setting
CURLOPT_IGNORE_CONTENT_LENGTH, only to receive an error stating "
no chunk, no close, no size. Assume close to signal end". I've tried several different permutations of these configurations. None of this worked.
I'm pretty desperate at this point. Obviously, the server hosting the video is misconfigured - and it's just for this particular video. Other videos from the same server can be accessed and downloaded correctly.
I guess my question is, does anyone here have any experience with this error? Any other suggestions? Also, how are Windows Media Player and the JWPlayer able to stream this apparently corrupted resource? Thanks for any information.
EDIT - As you can see, the video I'm trying to download is 273628708 bytes in size, approximately 1.5 hours of footage. Could this have something to do with it?