Skip to first unread message


Aug 24, 2017, 1:42:01 PM8/24/17
to iphone google group

    Trying to determine the ultimate URL in the case of an internet redirect. 

    Apple's documentation on this is unusually dense.  

    Can anyone point me at a simple example of some code that does this?  Objective-c preferred. 


W Janoch

Oct 15, 2019, 12:08:43 AM10/15/19

Sorry, no actual code to direct you to, just the principles for those inclined and able to write their own.

Usually, the code will follow the redirects and keep count until it reaches a predefined max depth, or until it detects a repeat.  Either way, it reports an error and exits, or it reports the final non-redirected url.

Each time you make a request, the response has a header, the header has a response code like 404 (meaning not found).  In your case, you’re interested in the 300’s as redirects, and 200 as OK meaning the resource is received.

If it’s anything else, that’s probably a show stopper, like 404 or 501 (not found or server error); neither one means you’ve reached the final intended destination, and you definitely haven’t found the resource you were looking for.

The only good finish is a 200, that’s what you’re after.  

If you follow more than 50 redirects without a status of 200 you should probably abort, maybe even after 3, if you’re not terribly desperate for the resource.  You should add each URL to a list and check the list for each new URL and quit if it’s already on the list.


P. S. HTTP Status Codes:

You received this message because you are subscribed to the Google Groups "iPhone SDK Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
For more options, visit

Reply all
Reply to author
0 new messages