Xcode-beta (6D532l)/iOS 8.3 beta 2 breaks setting "Accept" header value in NSURLSessionConfiguration.HTTPAdditionalHeaders
| Originator: | andrew | ||
| Number: | rdar://19935664 | Date Originated: | 24-Feb-2015 11:51 AM |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | Xcode-beta (6D532l) |
| Classification: | Serious Bug | Reproducible: | Always |
Summary:
When using code like this to set the HTTP “Accept” header:
let conf = NSURLSessionConfiguration.defaultSessionConfiguration()
conf.HTTPAdditionalHeaders = ["Accept": "application/json;odata=verbose"]
let session = NSURLSession(configuration: conf)
let url = NSURL(string: "http://ip.jsontest.com/")!
session.dataTaskWithURL(url).resume()
…and viewing the resulting request in a proxy like Charles Proxy, the “Accept” value no longer gets set in iOS 8.3 for both Simulator and device. This previously worked fine in iOS 7 and 8.1.3
Headers resulting from above code under iOS 7 & 8.1.3:
GET / HTTP/1.1
Host ip.jsontest.com
Accept application/json;odata=verbose
User-Agent AcceptHeaderB0rkag3Test/1 CFNetwork/672.1.13 Darwin/14.1.0
Accept-Language en-us
Accept-Encoding gzip, deflate
Connection keep-alive
Headers resulting from above code under iOS 8.3 (both beta 1 & 2):
GET / HTTP/1.1
Host ip.jsontest.com
Accept */*
User-Agent AcceptHeaderB0rkag3Test/1 CFNetwork/711.3.12 Darwin/14.1.0
Accept-Language en-us
Accept-Encoding gzip, deflate
Connection keep-alive
Steps to Reproduce:
1. Setup a device to route through a proxy like Charles Proxy, or any other tool that will let you view HTTP headers for requests made
2. Run the attached project
3. Press the “Make Request” button
4. Review HTTP headers
5. Observe the “Accept” header is not set - it remains */*
6. Re-run on iOS 8.1.3 and observe the header is set.
Expected Results:
I would expect setting the “Accept” header to still work as it has done on previous iOS releases.
Actual Results:
“Accept” header not set.
Regression:
Problem NOT present on iOS 7, 8.1.3
Problem IS present on iOS 8.3 beta 1 & 2
Notes:
This has actually broken an app I’m developing for a client, so it’s not a contrived example.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!