swiftlang / swift-corelibs-foundation

The Foundation Project, providing core utilities, internationalization, and OS independence
swift.org
Apache License 2.0
5.29k stars 1.13k forks source link

[SR-2974] URLSession loses headers #4316

Closed swift-ci closed 7 years ago

swift-ci commented 8 years ago
Previous ID SR-2974
Radar None
Original Reporter tfrank64 (JIRA User)
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Environment Ubuntu 14.04 Tested on DEVELOPMENT-SNAPSHOT-2016-09-15-a
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 4 | |Component/s | Foundation | |Labels | Bug | |Assignee | saiHema (JIRA) | |Priority | Medium | md5: ecb91bf9d235a756b79b5f367b8bf3a8

Issue Description:

This may be a duplicate of SR-2913.

When using the URLSession dataTask method, it loses the headers I give it somewhere in between making the request and receiving them through the Kitura framework, server-side.

The problem is intermittent, but happens pretty often. I created a sample project (see attachment) that reproduces the issue, simply run swift test a few times and eventually you will see the output "Headers: nil".

Additionally, I tested hitting my endpoint in the sample project through the Postman app, and it consistently worked, with authorization headers being transmitted correctly. Thus, I'm concluding, this is an issue with Swift.

Postman App: https://chrome.google.com/webstore/detail/postman/fhbjgbiflinjbdggehcddcbncdddomop?hl=en

swift-ci commented 7 years ago

Comment by Taylor Franklin (JIRA)

You will need to bump the packages up to run on Swift 3.0.1

    .Package(url: "https://github.com/IBM-Swift/Kitura.git", majorVersion: 1, minor: 1),
    .Package(url: "https://github.com/IBM-Swift/Swift-cfenv.git", majorVersion: 1, minor: 8)
swift-ci commented 7 years ago

Comment by sai Hema k (JIRA)

Unable to recreate the issue with Swift-3.1-development-snapshot

swift-ci commented 7 years ago

Comment by Taylor Franklin (JIRA)

Yes, I think with other work on URLSession and other libraries, this problem has been resolved.