We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 96cf3a5 + c3041ed commit 2d80441Copy full SHA for 2d80441
Foundation/NSURLSession/NSURLSessionTask.swift
@@ -839,10 +839,13 @@ extension URLSessionTask {
839
guard case .inMemory(let bodyData) = bodyDataDrain else {
840
fatalError("Task has data completion handler, but data drain is not in-memory.")
841
}
842
+
843
guard let s = session as? URLSession else { fatalError() }
-
844
- var data = Data(capacity: bodyData!.length)
845
- data.append(Data(bytes: bodyData!.bytes, count: bodyData!.length))
+ var data = Data()
846
+ if let body = bodyData {
847
+ data = Data(bytes: body.bytes, count: body.length)
848
+ }
849
850
s.delegateQueue.addOperation {
851
completion(data, response, nil)
0 commit comments