1

I was trying to make a download manager that supports resume. My app uses the cookies and headers got from Chrome browser via an extension that I have. I faced a problem when I tried to send partially request to a url that has Transfer-Encoding=chunked as header-value, which is a Google Drive file. The url has 1.3GB file size. When I tried to request Range:0-1MB it returns correct length, but Range:0-10MB returns the full content. I see that download managers like IDM can request ranges larger than 1MB to the same url. How can I send requests like that?

Note: The url is temporary and it is needed to add cookie got from browser to test.

var tabUrl = "https://drive.google.com/u/0/uc?export=download&confirm=03hU&id=0B1eUy3QmH0GJMnMzOTd0ZmxBTWs";
var downloadUrl = "https://doc-0g-b4-docs.googleusercontent.com/docs/securesc/lsbj6u3i2broqhjlhh1rgl1pur9nv89c/2ipaf9daok4r1ccc59df1knp3itb6ov6/1608404475000/05822274146576777383/05815548638186256017/0B1eUy3QmH0GJMnMzOTd0ZmxBTWs?e=download&authuser=0&nonce=carmpci74c5ie&user=05815548638186256017&hash=dm8janki6hh5u70h2t9t83t2gq922app";
var request = (HttpWebRequest)WebRequest.Create(downloadUrl);
request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.18362";
request.AllowAutoRedirect = true;
request.Method = "GET";
request.Timeout = 30000;
request.KeepAlive = false;
request.ReadWriteTimeout = 3000;
before.Raise(null, new BeforeSendingRequestEventArgs(request));
request.AddRange(0, 10 * 1024 * 1024);
var resp = (HttpWebResponse)request.GetResponse();
var contentLength = resp.ContentLength;

if(contentLength != 10 * 1024 * 1024 + 1)
   throw new Exception("Content size returned is wrong");
Ali Tor
  • 2,772
  • 2
  • 27
  • 58

0 Answers0