app需要修改3个地方
1.manager.responseSerializer.acceptableContentTypes =nil;
2.修改AFNetworkReachabilityManager.m文件,用下面函数替换原来的函数
+ (instancetype)manager {
double version = [[UIDevice currentDevice].systemVersion doubleValue];
if (version >= 9.0f) {
struct sockaddr_in6 address; bzero(&address, sizeof(address));
address.sin6_len = sizeof(address);
address.sin6_family = AF_INET6;
return [self managerForAddress:&address];
}else {
#if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 90000) || (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
struct sockaddr_in6 address;
bzero(&address,sizeof(address));
address.sin6_len = sizeof(address);
address.sin6_family = AF_INET6;
#else
struct sockaddr_in address;
bzero(&address,sizeof(address));
address.sin_len = sizeof(address);
address.sin_family = AF_INET;
#endif
return [self managerForAddress:&address];
}
}
3.网络请求代码这样写
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
manager.responseSerializer.acceptableContentTypes = nil;//[NSSet setWithObject:@"text/ plain"];
manager.securityPolicy = [AFSecurityPolicy defaultPolicy];
manager.securityPolicy.allowInvalidCertificates = YES;//忽略https证书
manager.securityPolicy.validatesDomainName = NO;//是否验证域名
网友评论