大致有两种做法:
1.一种是检测到有代理服务器,就不发送网络请求;
2.一种是不发送给代理服务器,而是正常发给目标服务器;
//检查是否有代理服务器
+ (BOOL)getProxyStatus
CFDictionaryRef dicRef = CFNetworkCopySystemProxySettings();
const CFStringRef proxyCFstr = CFDictionaryGetValue(dicRef, (const void*)kCFNetworkProxiesHTTPProxy);
CFRelease(dicRef);
NSString *proxy = (__bridge NSString*)(proxyCFstr);
if(proxy) {
return YES;
}
return NO;
}