Skip to content
Open
Changes from 2 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
6 changes: 5 additions & 1 deletion Sources/FoundationNetworking/URLSession/NativeProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,11 @@ internal class _NativeProtocol: URLProtocol, _EasyHandleDelegate {
}

guard let response = ts.response else {
fatalError("Transfer completed, but there's no response.")
internalState = .transferFailed
let error = NSError(domain: NSURLErrorDomain, code: NSURLErrorNetworkConnectionLost,
userInfo: [NSLocalizedDescriptionKey: "The network connection was lost."])
failWith(error: error, request: request)
return
}
internalState = .transferCompleted(response: response, bodyDataDrain: ts.bodyDataDrain)
let action = completionAction(forCompletedRequest: request, response: response)
Expand Down