-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Parity: Networking: URLUploadTask and URLDownloadTask #2293
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
Parity: Networking: URLUploadTask and URLDownloadTask #2293
Conversation
@swift-ci please test and merge |
@swift-ci please test |
@@ -32,8 +32,30 @@ open class URLSessionTask : NSObject, NSCopying { | |||
|
|||
/// How many times the task has been suspended, 0 indicating a running task. | |||
internal var suspendCount = 1 | |||
|
|||
internal var actualSession: URLSession? { return session as? URLSession } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was just wondering if we could create a property in URLSessionProtocol
to provide the task delegate, some like below. This way we could keep the communication between URLSessionTask
and URLSession
through an interface instead of a concrete class. What do you think about this approach?
// URLSession.swift
internal protocol URLSessionProtocol: class {
var taskDelegate: URLSessionTaskDelegate { get }
}
extension URLSession: URLSessionProtocol {
var taskDelegate: URLSessionTaskDelegate? { return delegate }
}
// URLSessionTask.swift
func getBody(completion: @escaping (_Body) -> Void) {
/* code */
if let delegate = session.taskDelegate {
/* code */
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly, the data is dispersed enough that it is an academic distinction.
@swift-ci please test |
1 similar comment
@swift-ci please test |
@@ -1304,25 +1391,3 @@ extension HTTPUploadDelegate: URLSessionDataDelegate { | |||
} | |||
} | |||
|
|||
class FailFastProtocol: URLProtocol { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a merge issue.
@swift-ci please test |
4 similar comments
@swift-ci please test |
@swift-ci please test |
@swift-ci please test |
@swift-ci please test |
- Implement downloadTask(withResumeData…). We do not currently support resume data, so act as Darwin does when invalid data is fed to these methods. - Implement uploadTask(withStreamedRequest:). - Some cleanup, some testing.
…resume data is invalid.
@swift-ci please test |
1 similar comment
@swift-ci please test |
Implement downloadTask(withResumeData…). We do not currently support resume data, so act as Darwin does when invalid data is fed to these methods.
Implement uploadTask(withStreamedRequest:).
Some cleanup, some testing.