meta http-equiv=“Refresh” and NSURLConnection
-
22-09-2019 - |
Question
I have a URL e.g. http://www.test.com that contains a meta redirect as follows:
<meta http-equiv="Refresh" content="0; url="http://www.trial.com ?>
However, - (void)connectionDidFinishLoading:(NSURLConnection *)connection
just returns the initial data from the first URL.
Is it now my responsibility to parse the returned HTML file and pull out the meta url attribute and call NSURLConnection again? Or is there a better way?
How secure is this approach?
It would probably be better to just use an alternative redirection method, but for now, this is the only one open to me...
Solution
If the refresh is in the HTML and you don't intend to let a UIWebView display it, it most certainly is your responsibility to parse the HTML and act on it (if you want to handle the redirect that is).
A simpler place to put the redirect is in the HTTP response -- that requires a bit more server access but most hosting places will let you do that.
OTHER TIPS
It would be better to use an alternative redirect, perhaps javascript or header redirects?