开发者

meta http-equiv="Refresh" and NSURLConnection

开发者 https://www.devze.com 2022-12-08 20:17 出处:网络
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 ?>

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...


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.


It would be better to use an alternative redirect, perhaps javascript or header redirects?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号