1

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?

4

1 回答 1

1

NSURLConnection(底层框架类)确实支持这种通知方式:

- (NSURLRequest *)connection:(NSURLConnection *)connection willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)response;

=> AFNetworking 通过在重定向发生时调用的块公开这个:

@property (readwrite, nonatomic, copy) AFURLConnectionOperationRedirectResponseBlock redirectResponse;

于 2013-05-27T15:33:59.157 回答