     self.handler = handler
 
     let config = URLSessionConfiguration.default
-    downloadSession = URLSession(configuration: config, delegate: self, delegateQueue: nil)
+    downloadSession = URLSession(configuration: config)
   }
 
   func addRequest(_ request: HTTPDownloadRequest) {

  func downloadQueueCancelled(_ queue: HTTPDownloader)
}

class HTTPDownloader: NSObject, URLSessionDelegate, URLSessionTaskDelegate, URLSessionDownloadDelegate,
URLSessionDataDelegate {
  var queue: [HTTPDownloadRequest] = []
  // TODO: Make unowned
  weak var handler: HTTPDownloadDelegate?

        log.error("Error saving the download: \(error)")
      }
    }

    DispatchQueue.main.async {
      self.handler?.downloadRequestFinished(currentRequest)
      self.runRequest()
    }
  }

  func dataCompletionHandler(data: Data?, response: URLResponse?, error: Error?) -> Void {
    guard let currentRequest = currentRequest else {
      return
    }

    guard let data = data else {
      DispatchQueue.main.async {
        self.handler?.downloadRequestFailed(currentRequest)
        self.runRequest()
      }
      return
    }
    // We only evaluate one at a time, so the 'current request' holds the data task's original request data.
    currentRequest.rawResponseData = data
    // With current internal settings, this will cache the data as we desire.

    DispatchQueue.main.async {
      self.handler?.downloadRequestFinished(currentRequest)
      self.runRequest()
    }
  }
