I am using a simple AFNetworking [AFHTTPRequestOperation -initWithRequest:] for downloading file, I would like to check for the response header "content length" before I can actually download the file. How can I check for response content length in AFNetworking ?
Using expectedContentLength Property of NSURLResponse You can you can find length.
AFHTTPRequestOperation *op = [[AFHTTPRequestOperation alloc] initWithRequest:request];
[op setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject)
{
NSLog(@"Content-lent: %lld", [operation.response expectedContentLength]);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With