Skip to content

Fix for SR-2913 - HTTP headers not picked up #681

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
Nov 10, 2016

Conversation

pushkarnk
Copy link
Member

@pushkarnk pushkarnk commented Oct 11, 2016

In startNewTransfer(with:) though we first set currentRequest property to the incoming request here, the update happens asynchronously on the taskAttributesIsolation queue. Subsequently, in curlHeaders(for: URLRequest) we use the currentRequest property assuming it has been set to get the HTTP headers.

If we end up picking up the HTTP headers before async block runs, we can get into problems. For new requests, the currentRequest property could still be nil, meaning the expected headers will not passed to libcurl. For redirections, we may pick up headers from the previous request.

I think it must be acceptable to use the incoming URLRequest parameter instead of the property. After all, the currentRequest property is expected to be set to the incoming URLRequest.

@pushkarnk
Copy link
Member Author

@swift-ci please test

@pushkarnk
Copy link
Member Author

pushkarnk commented Oct 20, 2016

Another problem reported currentRequest equal to nil here.

The taskAttributesIsolation queue which is used to make the public attributes thread safe should be a concurrent queue and writes should use barriers. Comments on line 74 make this intention clear but this wasn't implemented.

I've made suitable changes to the PR. Two versions of the problem documented in the SR are fixed with this.

@pushkarnk
Copy link
Member Author

@swift-ci please test

@parkera
Copy link
Contributor

parkera commented Nov 3, 2016

LGTM

@pushkarnk
Copy link
Member Author

@swift-ci please test

@pushkarnk
Copy link
Member Author

Looks like a compiler crash. Trying one more time.
@swift-ci please test

@pushkarnk
Copy link
Member Author

@swift-ci please test

@pushkarnk pushkarnk merged commit 37b6641 into swiftlang:master Nov 10, 2016
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