Reputation: 13
When I try to download a file with AFDownloadRequestOperation from a URL, the Wi-fi router turns off internet connection and redirects me to an authorization page. The download process does not stop during this redirection and I get an HTML redirection page instead of a file that was supposed to be downloaded. It tells me that it's okay and that the file is downloaded.
How can I determine that a download object is an html redirection page and stop downloading it before I get that page?
Upvotes: 1
Views: 266
Reputation: 50109
NSURLConnection (the underlying framework class) does support this sort of notificationvia:
- (NSURLRequest *)connection:(NSURLConnection *)connection willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)response;
=> AFNetworking exposes this via block that is to be called when a redirect happens:
@property (readwrite, nonatomic, copy) AFURLConnectionOperationRedirectResponseBlock redirectResponse;
Upvotes: 1