Skip to content

Add URLSessionDownloadTask.cancel(byProducingResumeData:) #1592

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

Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion Docs/Status.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ There is no _Complete_ status for test coverage because there are always additio
| `URLSessionTask` | Mostly Complete | Incomplete | `cancel()`, `createTransferState(url:)` with streams, and others remain unimplemented |
| `URLSessionDataTask` | Complete | Incomplete | |
| `URLSessionUploadTask` | Complete | None | |
| `URLSessionDownloadTask` | Incomplete | Incomplete | `cancel(byProducingResumeData:)` remains unimplemented |
| `URLSessionDownloadTask` | Incomplete | Incomplete | |
| `URLSessionStreamTask` | Unimplemented | None | |
| `TaskRegistry` | N/A | N/A | For internal use only |
| `TransferState` | N/A | N/A | For internal use only |
Expand Down
13 changes: 12 additions & 1 deletion Foundation/URLSession/URLSessionTask.swift
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,18 @@ open class URLSessionDownloadTask : URLSessionTask {
* If resume data cannot be created, the completion handler will be
* called with nil resumeData.
*/
open func cancel(byProducingResumeData completionHandler: @escaping (Data?) -> Void) { NSUnimplemented() }
open func cancel(byProducingResumeData completionHandler: @escaping (Data?) -> Void) {
super.cancel()

/*
* In Objective-C, this method relies on an Apple-maintained XPC process
* to manage the bookmarking of partially downloaded data. Therefore, the
* original behavior cannot be directly ported, here.
*
* Instead, we just call the completionHandler directly.
*/
completionHandler(nil)
}
}

/*
Expand Down