After upgrading to XCode 7 and running my app in the iOS9 simulator, any requests that I make that include an Authorization header time out. If I remove the authorization header, the request completes immediately. If I make the request via http with the header, it works just fine. It's not an issue of whether the auth header token is valid, just if the header is present. The server has a valid cert and meets the ATS requirements. I can curl the request with the authorization header with no problem. The Swift 1.2 version works fine in an XCode 6 playground. The CFNETWORK_DIAGNOSTICS produces a > 5MB log file when the authorization header is supplied, but doesn't give me any recognizable indication in the log. Any ideas?
I've reproduced in this playground:
// Swift 2.0 version
// This times out. But if you comment out config.HTTPAdditionalHeaders = headers line, it will return immediately.
import UIKit
import XCPlayground
XCPSetExecutionShouldContinueIndefinitely()
let URL = NSURL(string: "https://tempapi.universitylaundry.com/v1/accounts")
let config = NSURLSessionConfiguration.defaultSessionConfiguration()
let headers = [
"Authorization": "Bearer VLgUVjPJ-I0UZ1os41cQ58hjZOTt7St8TcyfURG8gO3prtN6BMskqt6ymA8ME5aaeCKiHjtZs5uc6Z63CUe7XPAe56E8Tt1OyYZZr9cRQvc8ys8Pgkxq5ELSLSnY_lbiZlrsRtuo45QtSQP73Pg-X6N1uaAm8Od07U8BZ4lHgYu2Z9g7QiW1P5QmTs_zCh_nzXmhrKe..."
]
config.HTTPAdditionalHeaders = headers
let session = NSURLSession(configuration: config)
let task = session.dataTaskWithURL(URL!, completionHandler: { (data, response, error) in
print("TaskCompleted")
print(NSString(data: data!, encoding: NSUTF8StringEncoding))
})
task.resume()