Skip to content

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

Merged
merged 4 commits into from
Aug 5, 2019
Merged

Parity: Networking: URLUploadTask and URLDownloadTask #2293

merged 4 commits into from
Aug 5, 2019

Conversation

millenomi
Copy link
Contributor

  • 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.

@millenomi
Copy link
Contributor Author

@swift-ci please test and merge

@millenomi
Copy link
Contributor Author

@millenomi
Copy link
Contributor Author

@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 }
Copy link
Contributor

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 */
    }
}

Copy link
Contributor Author

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.

@millenomi
Copy link
Contributor Author

@swift-ci please test

1 similar comment
@millenomi
Copy link
Contributor Author

@swift-ci please test

@@ -1304,25 +1391,3 @@ extension HTTPUploadDelegate: URLSessionDataDelegate {
}
}

class FailFastProtocol: URLProtocol {
Copy link
Contributor Author

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.

@millenomi
Copy link
Contributor Author

@swift-ci please test

4 similar comments
@millenomi
Copy link
Contributor Author

@swift-ci please test

@millenomi
Copy link
Contributor Author

@swift-ci please test

@millenomi
Copy link
Contributor Author

@swift-ci please test

@millenomi
Copy link
Contributor Author

@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.
@millenomi
Copy link
Contributor Author

@swift-ci please test

1 similar comment
@millenomi
Copy link
Contributor Author

@swift-ci please test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants