From 13245b4514cae45485438c67c8564ae8c0afb002 Mon Sep 17 00:00:00 2001 From: Harlan Haskins Date: Sat, 8 Feb 2025 13:22:42 -0500 Subject: [PATCH] Ensure the transfer state is properly updated with the task's response We seem to be dropping the response in this case, just ensure we actually save it after the transfer has completed. --- Sources/FoundationNetworking/URLSession/NativeProtocol.swift | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Sources/FoundationNetworking/URLSession/NativeProtocol.swift b/Sources/FoundationNetworking/URLSession/NativeProtocol.swift index ad6836dc9a..0434aacfd4 100644 --- a/Sources/FoundationNetworking/URLSession/NativeProtocol.swift +++ b/Sources/FoundationNetworking/URLSession/NativeProtocol.swift @@ -224,7 +224,7 @@ internal class _NativeProtocol: URLProtocol, _EasyHandleDelegate { failWith(error: error!, request: request) return } - guard case .transferInProgress(let ts) = internalState else { + guard case .transferInProgress(var ts) = internalState else { fatalError("Transfer completed, but it wasn't in progress.") } guard let request = task?.currentRequest else { @@ -232,8 +232,7 @@ internal class _NativeProtocol: URLProtocol, _EasyHandleDelegate { } if let response = task?.response { - var transferState = ts - transferState.response = response + ts.response = response } guard let response = ts.response else {