I'm downloading a zipped folder from dropbox, by adding the ?dl=1 code at the end of the shared link.
Everything works fine and dandy, except for the connection response content length field. When I check response.expectedContentLength value, it always comes up as -1
I've tried avoiding response gzip compression with
[httpRequest setValue:@"" forHTTPHeaderField:@"Accept-Encoding"];
I've tried checking in the didReceiveResponse method if expectedContentLength was -1 and doing a manual check just for headers using the absolute zip file link (contained in response.URL) with
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:response.URL
cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData
timeoutInterval:10];
theRequest.timeoutInterval = 5.0;
theRequest.HTTPMethod = @"HEAD";
NSHTTPURLResponse *res;
NSData * resData = [NSURLConnection sendSynchronousRequest:theRequest returningResponse:&res error:nil];
long length = res.expectedContentLength;
"length" still comes up as -1.
The zip is generated by dropbox on the fly, so the initial request might be unable to get the content length. But in theory the response.URL value SHOULD be the final zipped file, and requesting it's headers should return a proper contentLength field, right?
Any ideas?
For anyone coming here later on:
I never got to find a way of getting it, short of fully downloading it (which kinda defeats the purpose), so that's that. This is something you can't access (written on 16/06/16, do check again when you read). Dropbox doesn't set that particular header when downloading zipped folders.