Skip to content

URLProtocolClient doesn't deliver response and data to URLSession delegates #1084

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 1 commit into from
Jun 28, 2017
Merged

URLProtocolClient doesn't deliver response and data to URLSession delegates #1084

merged 1 commit into from
Jun 28, 2017

Conversation

nethraravindran
Copy link
Contributor

Custom URLProtocols using task delegates doesn't deliver data and response received to the URLSession delegates. This fix would delegate the data and response to url session delegates.

guard let task = `protocol`.task else { fatalError("Received response, but there's no task.") }
task.response = response
let session = task.session as! URLSession
guard let dt = task as? URLSessionDataTask else { return }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Can we have a better name for the local here? May be dataTask

let dataDelegate = delegate as? URLSessionDataDelegate
let dataTask = task as? URLSessionDataTask
session.delegateQueue.addOperation {
dataDelegate?.urlSession(session, dataTask: dataTask!, didReceive: `protocol`.properties[URLProtocol._PropertyKey.responseData] as! Data)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can simply use data as the didReceive argument here!

@pushkarnk
Copy link
Member

@nethraravindran Can you please edit the commit message so that it indicates the problem in the Foundation context? Thanks.

@pushkarnk
Copy link
Member

@swift-ci please test and merge

1 similar comment
@pushkarnk
Copy link
Member

@swift-ci please test and merge

@swift-ci swift-ci merged commit 183cd13 into swiftlang:master Jun 28, 2017
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.

3 participants