浏览了 NSURLSession
和 NSURLSessionConfiguration
的文档之后,我认为我应该使用如下的字典进行配置:
// Create a dictionary to describe the proxy
NSDictionary *proxyDict = @{
(NSString *)kCFProxyHostNameKey : @"myProxyHost.com",
(NSString *)kCFProxyPortNumberKey : @"12345",
(NSString *)kCFProxyTypeKey : (NSString*)kCFProxyTypeHTTP
};
// Create a configuration that uses the dictionary
NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
[configuration setConnectionProxyDictionary:proxyDict];
但是,使用此配置创建的NSURLSession
请求将直接连接。
^(NSData *data, NSURLResponse *response, NSError *error)
返回的数据给出的是 myProxyHost.com 的结果,而不是 www.google.com。你能帮我吗? - Balaji Kondalrayal