Hi,
I am running below code to send request within URLSession data task, but the delegate methods are not called, but get called if I change to other url, for example "https://m1.m.dm/dp/authServices.htm".
class ViewController: UIViewController {
var receivedData: Data?
private lazy var session: URLSession = {
let configuration = URLSessionConfiguration.default
configuration.waitsForConnectivity = true
return URLSession(configuration: configuration,
delegate: self, delegateQueue: nil)
}()
override func viewDidLoad() {
super.viewDidLoad()
startLoad()
}
func startLoad() {
let url = URL(string: "https://m5.m.dm/dp/authServices.htm")!//delegate never called by URLSession
let task = session.dataTask(with: url)
task.resume()
}
}
extension ViewController: URLSessionDelegate, URLSessionTaskDelegate, URLSessionDataDelegate {
// MARK: - URLSessionTaskDelegate
func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: Error?) {
}
// MARK: URLSessionDataDelegate
func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, didReceive response: URLResponse, completionHandler: @escaping (URLSession.ResponseDisposition) -> Void) {
completionHandler(.allow)
}
func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, didReceive data: Data) {
}
}