Get the last redirected url in iOS 5?

后端 未结 2 665
天涯浪人
天涯浪人 2021-01-22 17:39

Can someone please post the simplest of working code that can get the last redirected url(nth) when I GET request a url?

I know I need to use asynchronous requests but

相关标签:
2条回答
  • 2021-01-22 18:32

    Please read Handling Redirects and Other Request Changes in the documentation. Briefly, you'll want to a) provide a delegate for your connection, and b) implement the method connection:willSendRequest:redirectResponse: in said delegate. I don't understand exactly what you're trying to do in your question -- do you just want the data from URL to which your connection is redirected, or do you want to see the redirected request? Either way, implementing the method above should help. Your delegate will be able to see the redirected request, and returning it unchanged should cause the connection to load the new URL.

    0 讨论(0)
  • 2021-01-22 18:33

    We can achieve this with NSMutableURLRequest. I had followed these steps, it's working fine for me. Go through with below mentioned Link.

    URL: Click here: Get the final redirected url

    P.S: Let me know if you need further help.

    0 讨论(0)
提交回复
热议问题