Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure URLSessionDataTask response is not dropped #5167

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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