Catching the redirected address from NSURLConnection
Posted
by
Vic
on Stack Overflow
See other posts from Stack Overflow
or by Vic
Published on 2011-01-08T23:13:05Z
Indexed on
2011/01/09
0:53 UTC
Read the original article
Hit count: 238
I'm working on a software which follows the HTTP redirection which is dynamically calculated by the server depending on a pparameter. I don't want to show the primary server in Mobile Safari but rather the redirected address only. The following code workks:
request = [NSMutableURLRequest requestWithURL:originalUrl cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:10];
[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
// Extract the redirected URL
target = [response URL];
The problem is that the server requires several seconds to answer. The sendSynchronousRequest
blocks the app for this time completely which is messy, I can't even display the "Busy" animation.
Does anyone know how I can retrieve the redirected address asynchronously without safari appearance in the meanwhile with the redirecting server URL or display some sort of the "Be patient" animation during the sendSynchronousRequest
? What disadvantages would have the passing of sendSynchronousRequest
in another thread?
© Stack Overflow or respective owner