gpt4 book ai didi

iphone - 将 NSMutableURLRequest 超时设置为自定义时间

转载 作者:可可西里 更新时间:2023-11-01 04:40:34 28 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
NSMutableURLRequest timeout doesn't trigger if data starts to load but not webViewDidFinishLoad

我正在使用异步 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];

我正在实现以下委托(delegate):

- (void)connection:(NSURLConnection *)iConnection didReceiveResponse:(NSURLResponse *)iResponse;
- (void)connection:(NSURLConnection *)iConnection didReceiveData:(NSData *)iElementContructionContextData;
- (void)connection:(NSURLConnection *)iConnection didFailWithError:(NSError *)iError;

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com