I’m seeing differences between Linux and Mac when trying to do a POST with a URLSessionDataTask - it seems like URLRequest.httpBody is ignored on Linux, so POSTs arrive with an empty body.
Was I relying on undefined behaviour, or is this just not yet implemented?
The following captures the difference in behaviour:
import Foundation
import Dispatch
var req = URLRequest(url: URL(string: "http://httpbin.org/post"\)!)
req.httpMethod = "POST"
req.httpBody = "Hello! You should see me in the 'form' parameter of the result.".data(using: .utf8)
let sesh = URLSession(configuration: URLSessionConfiguration.default)
let dataTask = sesh.dataTask(with: req) { data, _, _ in
print(String(data: data!, encoding: .utf8)!)
exit(0)
}
dataTask.resume()
dispatchMain()
I’m seeing differences between Linux and Mac when trying to do a POST with a URLSessionDataTask - it seems like URLRequest.httpBody is ignored on Linux, so POSTs arrive with an empty body.
Was I relying on undefined behaviour, or is this just not yet implemented?
The following captures the difference in behaviour:
import Foundation
import Dispatch
var req = URLRequest(url: URL(string: "http://httpbin.org/post")!)
req.httpMethod = "POST"
req.httpBody = "Hello! You should see me in the 'form' parameter of the result.".data(using: .utf8)
let sesh = URLSession(configuration: URLSessionConfiguration.default)
let dataTask = sesh.dataTask(with: req) { data, _, _ in
print(String(data: data!, encoding: .utf8)!)
exit(0)
}
dataTask.resume()
dispatchMain()
Generally, should I be filing bugs for corelibs? I occasionally run into various issues (eg. uploadTask has different parameter naming) but I’m conscious that it’s not complete and probably most issues are already known and being worked on.
Thanks!
···
On 12 Sep 2016, at 09:25, Pushkar N Kulkarni <pushkar.nk@in.ibm.com> wrote:
Hi Michael,
I took a quick look at the URLSession code and it looks like the httpBody isn't being picked up anywhere.
Generally, should I be filing bugs for corelibs? I occasionally run into various issues (eg. uploadTask has different parameter naming) but I’m conscious that it’s not complete and probably most issues are already known and being worked on.
Absolutely! We’ve done a lot of work to try and make things match, but since it’s a manual process there are things we’ve missed. Please let us know when you find a discrepancy.
Some things are omitted intentionally, but if the same method exists with different parameter names it’s probably an oversight.
- Tony
···
On Sep 12, 2016, at 12:52 AM, Michael Ferenduros via swift-corelibs-dev <swift-corelibs-dev@swift.org> wrote:
On 12 Sep 2016, at 09:25, Pushkar N Kulkarni <pushkar.nk@in.ibm.com> wrote: