2

由于我将 AFNetworking 从 3.0.4 更新到 3.1.0,因此下载文件时出现错误 -999。我正在使用一些数据向服务器发出发布请求,如果数据有效,则将下载文件,否则将返回错误 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 setTimeoutInterval:DEFAULT_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];
4

1 回答 1

0

以下是您的问题提到的几个问题,请查看;

https://github.com/AFNetworking/AFNetworking/issues/2895

https://github.com/AFNetworking/AFNetworking/issues/2312

于 2016-05-27T13:56:47.657 回答