let task = Task {
let (data, response) = try await URLSession.shared.data(from: URL(string: "https://some-image-url.com")!)
// ...
}
And then I do task.cancel(), does URLSession automatically cancel the URLSessionTask as well? It seems careless to assume that the URLSessionTask is cancelled too, but I can't find any documentation on this matter. However, if the URLSessionTask is not automatically cancelled, then I'm forced to use the closure-based URLSession.dataTask(with:,completionHandler:) to get a reference to the URLSessionTask, and then to also call something like dataTask.cancel() on top of task.cancel(), which is somewhat odd.