Let's say we have an HTTP request that returns a 302 response with cookies. When using NSURLSessionTask with a delegate, the cookies are not included in the redirect request.
let (data, response): (Data, URLResponse) = try await withCheckedThrowingContinuation { continuation in
let task = session.dataTask(with: request) { (data, response, error) in
if let error = error {
continuation.resume(throwing: error)
} else {
continuation.resume(returning: (data!, response!))
}
}
task.delegate = delegate
task.resume()
}
The issue can be reproduced by this project.