Hi Michael,
I took a quick look at the URLSession code and it looks like the httpBody isn't being picked up anywhere.
Could you please create a bug report on https://bugs.swift.org ?
Pushkar N Kulkarni,
Thank you!
Pushkar N Kulkarni,
IBM Runtimes
Simplicity is prerequisite for reliability - Edsger W. Dijkstra
-----swift-corelibs-dev-boun...@swift.org wrote: -----
To: swift-corelibs-dev <swift-corelibs-dev@swift.org>
From: Michael Ferenduros via swift-corelibs-dev
Sent by: swift-corelibs-dev-boun...@swift.org
Date: 09/11/2016 02:16AM
Subject: [swift-corelibs-dev] Inconsistent URLSession POST behaviour
From: Michael Ferenduros via swift-corelibs-dev
Sent by: swift-corelibs-dev-boun...@swift.org
Date: 09/11/2016 02:16AM
Subject: [swift-corelibs-dev] Inconsistent URLSession POST behaviour
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()
_______________________________________________
swift-corelibs-dev mailing list
swift-corelibs-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-corelibs-dev
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()
_______________________________________________
swift-corelibs-dev mailing list
swift-corelibs-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-corelibs-dev
_______________________________________________ swift-corelibs-dev mailing list swift-corelibs-dev@swift.org https://lists.swift.org/mailman/listinfo/swift-corelibs-dev