Hi all,
I have this problem that is driving me insane. I am using the WillSendRequest RedirectResponse delegate method of NSURLConnection to find out if I am being redirected. The problem is that it doesn't work properly. RedirectResponse for some reason is always nil, and "request" seems to be the original request instead of the request with the redirect url.
Any idea why it is doing this?
Please help.
Here is the code:
I have this problem that is driving me insane. I am using the WillSendRequest RedirectResponse delegate method of NSURLConnection to find out if I am being redirected. The problem is that it doesn't work properly. RedirectResponse for some reason is always nil, and "request" seems to be the original request instead of the request with the redirect url.
Any idea why it is doing this?
Please help.
Here is the code:
Code:
-(NSURLRequest *)connection:(NSURLConnection *)connection willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse
{
NSURLRequest *newRequest=request;
NSLog(@"Request: %@",[[request URL] absoluteURL]);
NSLog(@"The Request: %@",[[theRequest URL] absoluteURL]);
if (redirectResponse) {
NSLog(@"redirect requested!");
[connection cancel];
[connection release];
[receivedData release];
[updateController cancelDownloaders];
[updateController alertSimpleAction: @"Could not download file. \n Please check your username and password"];
newRequest=nil;
}
return newRequest;
}