Simply set the timeouts after you create the HTTP component:
http := TIdHTTP.Create(nil);
http.ReadTimeout := 30000; // 30 seconds
http.ConnectTimeout := 10000; // 10 seconds
The above are timeout values that I often use. Though, you may want to use lower values and also be notified if the web sites are slow to respond.
The HTTP component will raise an exception if either timeout is exceeded.
Consider initializing code
in your for
loop to keep yourself out of trouble with future code changes, though as it stands, it's fine.
Also, consider not automatically adding www.
to each host name in your list. Instead, if your hostname requires www.
in it, add it to the list. In fact, you may wish to test both. Quite often, one simply redirects to the other, but you have the potential of losing customers if either of them is not working.
As suggested in comments, it would be ideal to run this in a separate thread than your main thread to keep your UI responsive.