I'm trying to write a rude application to loop around some HTTP header fields coming back from my server to find out which servers are responding OK. My servers respond with a header like this: server = server1 (or server2, server 3, etc.).
Unfortunately, when I do this, I get the same server name again and again from the application, until I stop it and restart it, after which I get another server. How can i stop this? I need an application to handle each connection, as if it were completely new, but it looks like it caches something and seems to come from one place, so my balancer returns the same server name.
I can repeat this behavior (expected) in Safari by going to my URL without disconnecting Safari - it gets the same server every time, but if I turn off Safari, go back there, I get a new server.
The code I use is as follows:
for (int i = 0; i < 999; i++) {
request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:10];
[NSURLConnection sendSynchronousRequest: request returningResponse: &response error: nil];
if ([response respondsToSelector:@selector(allHeaderFields)]) {
dictionary = [response allHeaderFields];
fullHeaderString = [dictionary description];
}
}
How can I make this connection be processed as new every time?
Cheers, Tom
source
share