Hi, i want to implement a Proxy in my WebView Controller, but i have problems trying to get the response of the URL, i tried almost everything.
I my main doubts are in the definition of the connectionProxyDictionary, my proxy server is an HTTPS server, and this is my code:
func loadAddressURL(url : String){
/
/
var proxyHost : CFString = NSString(string: "https://xxx.xxx.xxx") as CFString
var proxyPort : CFNumber = NSNumber(int: xxx) as CFNumber
var proxyEnable : CFNumber = NSNumber(int: 1) as CFNumber
/
var proxyDict: [NSObject : AnyObject] = [
kCFNetworkProxiesHTTPEnable: proxyEnable,
kCFStreamPropertyHTTPProxyHost: proxyHost,
kCFStreamPropertyHTTPProxyPort: proxyPort,
kCFStreamPropertyHTTPSProxyHost: proxyHost,
kCFStreamPropertyHTTPSProxyPort: proxyPort,
kCFProxyTypeKey: kCFProxyTypeHTTPS
]
var configuration : NSURLSessionConfiguration = NSURLSessionConfiguration.ephemeralSessionConfiguration()
configuration.connectionProxyDictionary = proxyDict
/
var session : NSURLSession = NSURLSession(configuration: configuration, delegate: self, delegateQueue: NSOperationQueue.mainQueue())
/
let requestURl = NSURL(string: url)
let request = NSURLRequest(URL:requestURl!)
/
var task : NSURLSessionDataTask = session.dataTaskWithRequest(request, completionHandler: {(data: NSData!, response: NSURLResponse!, error: NSError!) -> Void in
if (error == nil) {
var myHtmlString = NSString(data: data, encoding: NSUTF8StringEncoding)
println(response)
println(myHtmlString)
self.WebView.loadHTMLString(myHtmlString as! String, baseURL: nil)
} else {
println(error)
}
})
task.resume()
}the response is Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo=0x1740f1f00 {NSUnderlyingError=0x17405d550 "The operation couldn’t be completed. (kCFErrorDomainCFNetwork error -1001.)", NSErrorFailingURLStringKey=https://www.google.com/, NSErrorFailingURLKey=https://www.google.com/, NSLocalizedDescription=The request timed out.}
Thank you in Advance
Franz