gpt4 book ai didi

ios - 客户端在收到完整响应 AFNetworking 之前关闭连接

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:34:34 26 4
gpt4 key购买 nike

无法下载文件收到此错误“客户端在收到完整响应之前关闭了连接”我要下载的文件只有 266KB

     for (NSString *downloadURL in arr) {
// NSString *downloadURL = [d objectForKey:@"url"];
dispatch_async(dispatch_get_main_queue(), ^{
NSLog(@"URL for downloading : %@",downloadURL);
NSArray *pathArray = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask,YES);
NSString *documentsDirectory = [pathArray objectAtIndex:0];
NSString *downloadedZipPath = [documentsDirectory stringByAppendingPathComponent:TEMP_DICTIONARY];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:downloadURL]];
// [request addValue:@"bytes=x-" forHTTPHeaderField:@"Range"];
// [request setTimeoutInterval:20];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];

operation.outputStream = [NSOutputStream outputStreamToFileAtPath:downloadedZipPath append:NO];

[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"Success");
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];

[operation start];
});

尝试增加 api 请求超时但仍然无效

最佳答案

尝试将它设置为更多时间

[request setTimeoutInterval:20];

关于ios - 客户端在收到完整响应 AFNetworking 之前关闭连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33608425/

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