Still having problem with timeout on NSURLConnection _not_ resulting in connection failure
Still having problem with timeout on NSURLConnection _not_ resulting in connection failure
- Subject: Still having problem with timeout on NSURLConnection _not_ resulting in connection failure
- From: Glenn Zelniker <email@hidden>
- Date: Tue, 14 Mar 2006 02:04:09 -0500
To recap, I have an NSURLConnection that is created from a
NSMutableURLRequest where I set the timeoutInterval to, say, ten
seconds. This is part of an application that works reliably almost
all the time. Here's how I do it:
NSURL *url = [NSURL URLWithString:myURL];
NSMutableURLRequest *request = [NSMutableURLRequest
requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData
timeoutInterval:10.0f];
[request setHTTPMethod:@"POST"];
[request addValue:@"Application/Binary" forHTTPHeaderField:@"Content-
Type"];
[request addValue:[NSString stringWithFormat:@"%i", mySize]
forHTTPHeaderField:@"Content-Length"];
[request setHTTPBody:myData];
[request setHTTPShouldHandleCookies:YES];
NSURLConnection *uploadBlockConnection = [[NSURLConnection alloc]
initWithRequest:request delegate:self];
The delegation works just fine -- didReceiveData, didReceiveResponse,
didFinishLoading all work. Furthermore, connection:didFailWithError:
SOMETIMES works, and therein lies the problem. If I break the
Internet connection, the delegate gets the failure message with the
appropriate error code right away. But it appears that
connection:didFailWithError: will _not_ get called when the
connection times out (I can simulate a timeout by tweaking the server
code to not respond to a connection with a certain "fail" parameter
in the URL string).
I can't for the life of me figure out why a timeout wouldn't generate
a failure. Is there something I'm forgetting to set? Is it something
unique to a mutable request as opposed to an immutable request? (I
use the mutable variant because I need to do a POST). Might it have
something to do with the cache policy I've selected above?
I'm getting desperate!
Glenn Z
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden