Krumelur
Krumelur

Reputation: 32497

NSURLConnection and keep-alive

I have a small bug in my client app that uses NSURLConnection. I have tracked it down to an unexpected connection keep-alive that seems to confuse the web server (probably a bug on the server side). The workaround would be to force-close all outstanding connections at a certain point. Can I do this somehow with NSURLConnection, i.e. something like

[NSURLConnection closeAllIdleConnections];

Upvotes: 6

Views: 4073

Answers (2)

Kris Markel
Kris Markel

Reputation: 12112

ASIHTTPRequest has an expirePersistentConnections method. It may do what you're looking for.

It's not a drop-in replacement for NSURLConnection, but it's not too hard to port code from NSURLConnection to ASIHTTPRequest.

Upvotes: 1

Andrew Little
Andrew Little

Reputation: 6626

I think you might want to look at the following method defined for NSURLConnections. This assumes that you made the call asynchronously. If it isn't an async call, then it probably should be.

cancel Cancels an asynchronous load of a request.

  • (void)cancel

Discussion Once this method is called, the receiver’s delegate will no longer receive any messages for this NSURLConnection.

Hope this helps. Andrew.

Upvotes: 0

Related Questions