Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Dec 29, 2009, 12:06 PM   #1
roeik
macrumors member
 
Join Date: Dec 2008
NSURLConnection Delegate RedirectResponse is always nil

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:


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;
}
roeik is offline   0 Reply With Quote
Old Dec 30, 2009, 02:37 AM   #2
roeik
Thread Starter
macrumors member
 
Join Date: Dec 2008
Anyone??

I am surprised nobody had this problem before.

I would take any advice about hot to top a connection when the request is being redirected to another page.
roeik is offline   0 Reply With Quote
Old Dec 30, 2009, 07:12 AM   #3
robbieduncan
Demi-God (Moderator)
 
robbieduncan's Avatar
 
Join Date: Jul 2002
Location: London
1) Don't bump your posts. It's amazingly rude and arrogant as well as being against the forum rules. So much so that I almost did not post point 2

2) As per the documentation redirectResponse "May be nil in cases where this method is not being sent as a result of involving the delegate in redirect processing."
robbieduncan is online now   0 Reply With Quote
Old Dec 30, 2009, 08:27 AM   #4
roeik
Thread Starter
macrumors member
 
Join Date: Dec 2008
Hi,

Regarding point 1, Sorry. I am not sure what you mean by bump up, but I apologize if I caused you any damage of any sort. The last thing i meant was to be arrogant or rude, and again, I am deeply sorry if I broke the forum rules. Thank you for letting me know.

Regarding point 2, I read the documentation as well and saw this point, but I guess it was and still is vague to me. And it doesn't solve me the problem. My URLResponse is being redirected to another page, yet the redirect delegate method is being called and the redirect is nil. Why would this method get called if there is no redirect call? I don't understand.
roeik is offline   0 Reply With Quote
Old Dec 30, 2009, 08:36 AM   #5
robbieduncan
Demi-God (Moderator)
 
robbieduncan's Avatar
 
Join Date: Jul 2002
Location: London
I think you are misunderstanding what the redirectResponse should/will contain. In the case where you receive a redirect and the delegate has not yet been involved the redirectResponse will be nil (this is my understanding of what the documentation is saying). The request variable is what will be sent (i.e. where you have been redirected to). If you want to alter than you should copy and change it before returning.
robbieduncan is online now   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
NSURLConnection, delegate methods dont get called estupefactika iPhone/iPad Programming 21 Sep 6, 2012 02:47 PM
NSURLConnection for multiple views not receiving data asynchronously ashwinr87 iPhone/iPad Programming 13 Nov 3, 2011 05:47 PM
Exchange Delegation Support on iPad in Mail Supa_Fly iPad 9 Jul 4, 2011 04:11 PM
CALayer.bounds - why is it always nil ?? teek iPhone/iPad Programming 3 Apr 2, 2010 05:13 AM
nstableview delegate method is not getting called hrishidev Mac Programming 1 Nov 24, 2008 05:19 AM


All times are GMT -5. The time now is 04:46 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

Privacy / DMCA contact / Affiliate and FTC Disclosure
Copyright 2002-2013, MacRumors.com, LLC