Skip to content

Commit

Permalink
Ensure the transfer state is properly updated with the task's response
Browse files Browse the repository at this point in the history
We seem to be dropping the response in this case, just ensure we actually save it
after the transfer has completed.
  • Loading branch information
harlanhaskins committed Feb 8, 2025
1 parent 0129358 commit 13245b4
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions Sources/FoundationNetworking/URLSession/NativeProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -224,16 +224,15 @@ 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 {
fatalError("Transfer completed, but there's no current request.")
}

if let response = task?.response {
var transferState = ts
transferState.response = response
ts.response = response
}

guard let response = ts.response else {
Expand Down

0 comments on commit 13245b4

Please sign in to comment.