我想通过https在服务器上使用用户和密码,并在Swift 3上使用Alamofire 4获取一些JSON Feed
let urlRequest = URLRequest(url: URL(string: "https://myserver.com:123/apps/?cmd=getjson")!)
let urlString = urlRequest.url?.absoluteString
let user = "myuser"
let passwort = "one password"
let credential = URLCredential(user: user, password: passwort, persistence: .forSession)
let configuration = URLSessionConfiguration.default
configuration.requestCachePolicy = NSURLRequest.CachePolicy.reloadIgnoringLocalAndRemoteCacheData
configuration.timeoutIntervalForResource = 15
let almomanager = SessionManager(configuration:configuration)
almomanager.request( urlString! )
.authenticate(usingCredential: credential)
.responseJSON { response in
debugPrint(response)
}
但是
失败了Error Domain=NSURLErrorDomain Code=-999 "cancelled"
使用较旧版本的Alamofire和Swift,它运行正常! 我的错误在哪里?