While writing the new Image Downloader (Blocking) QC patch for CoreMelt, I ran into what appears to be a bug in Mac OS X’s NSURLConnection framework — if you construct an NSURLRequest and specify a timeout of less than 30 seconds, it’s ignored when you perform a [NSURLConnection sendSynchronousRequest:returningResponse:error:]. The request takes at least 30 seconds to time out, contrary to what the documentation suggests..
- Construct an NSURL with an http-based url pointing to a server that is currently offline.
- Execute the following code block:
NSLog(@"begin"); NSURLRequest *request=[NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:5.0]; NSData *data=[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error]; NSLog(@"end"); - Compare the timestamps of “begin” and “end”. though they should presumably differ by 5 seconds, they actually differ by exactly 30 seconds.
Any ideas?
On a somewhat related note, IOBluetooth inquiries have an application-configurable timeout that defaults to 10 seconds (the input is an unsigned char, so one would assume that it could inquire for up to 255 seconds). However, it appears to disregard this setting as well (on 10.5).
By cwright on 12.05.07 22:11 | Permalink