5
可能重复:
NSMutableURLRequest timeout doesn't trigger if data starts to load but not webViewDidFinishLoad为NSMutableURLRequest设置时间来定义时间
我使用的是异步HTTP请求,我NSMutableURLRequest设置超时时间为30秒,我想超时在这段时间内的请求。
问题:请求没有超时30秒。超时总是需要90秒。任何解决方案。
这里是我的连接代码:
NSMutableURLRequest *myRequest = [[NSMutableURLRequest alloc] initWithURL:myURL cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:30];
[myRequest setHTTPMethod:@"POST"];
[myRequest setHTTPBody:myData];
NSURLConnection *myConnection = [[NSURLConnection alloc] initWithRequest:myRequest delegate:self];
而且我采取以下delgates:
- (void)connection:(NSURLConnection *)iConnection didReceiveResponse:(NSURLResponse *)iResponse;
- (void)connection:(NSURLConnection *)iConnection didReceiveData:(NSData *)iElementContructionContextData;
- (void)connection:(NSURLConnection *)iConnection didFailWithError:(NSError *)iError;