开发者

Timeout doesn't work properly in the NSMutableURLRequest. But, why?

开发者 https://www.devze.com 2023-03-19 15:59 出处:网络
NSMutableDictionary* headers = [[[NSMutableDictionary alloc] init] autorelease]; [headers setValue:@\"application/x-www-form-urlencoded;charset=utf-8\" forKey:@\"Content-Type\"];
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 delega开发者_运维知识库te:delegate];

My TIMEOUT_REQUEST=30 seconds , but sometimes i'm waiting for 80 seconds before I'll get didFailWithError. But, why?

0

精彩评论

暂无评论...
验证码 换一张
取 消