自从我将 AFNetworking 从 3.0.4 更新到 3.1.0 后,下载文件时出现错误 -999。我正在使用一些数据向服务器发出 post 请求,如果数据有效,将下载文件,否则将返回错误 JSON。
代码如下:
AFSecurityPolicy *policy = [[AFSecurityPolicy alloc] init];
[policy setAllowInvalidCertificates:YES];
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
[manager setSecurityPolicy:policy];
manager.requestSerializer = [AFJSONRequestSerializer serializer];
manager.responseSerializer = [AFCompoundResponseSerializer serializer];
[manager.requestSerializer setTimeoutIntervalEFAULT_TIMEOUT];
[manager POST:[[BASE_URL stringByAppendingString:ACTION_UPDATE_DB] stringByAppendingString:API_KEY]
parameters:defaultData
progress:nil
success:^(NSURLSessionDataTask * _Nonnull task, id responseObject) {
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
}];
我试过改成这个,结果还是一样。
AFSecurityPolicy* policy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeCertificate];
[policy setAllowInvalidCertificates:YES];
[policy setValidatesDomainName:NO];
Best Answer-推荐答案 strong>
以下是您的问题提到的几个问题,请检查一下;
https://github.com/AFNetworking/AFNetworking/issues/2895
https://github.com/AFNetworking/AFNetworking/issues/2312
关于ios - AFNetworking 请求失败并显示 -999 错误代码,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/37484966/
|