超时在NSMutableURLRequest中无法正常工作。但为什么?

时间:2011-07-11 15:38:03

标签: iphone nsurlrequest nsmutableurlrequest

NSMutableDictionary* headers = [[[NSMutableDictionary alloc] init] autorelease];
[headers setValue:@"application/x-www-form-urlencoded;charset=utf-8" forKey:@"Content-Type"];
[headers setValue:@"text/html" forKey:@"Accept"];
[headers setValue:@"no-cache" forKey:@"Cache-Control"];
[headers setValue:@"no-cache" forKey:@"Pragma"];
[headers setValue:@"close" forKey:@"Connection"];

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:TIMEOUT_REQUEST];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:body];
[self createConnectionWithRequest:request delegate:delegate];

我的TIMEOUT_REQUEST = 30秒,但有时候我会等待80秒然后才会收到didFailWithError。但是,为什么?

0 个答案:

没有答案