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
[SR-2617] corelibs-foundation URLSession.dataTask() ignores httpBody #4447
Comments
Comment by Chris Bailey (JIRA) The The call to
Its fairly straightforward to fix that - however it doesn't fix the overall test case due to a second problem - on Linux we fail to set the I'll raise a PR for the first part to try to get that in as quickly as possible. The second part can be temporarily worked around by setting the header value manually using:
|
Comment by Chris Bailey (JIRA) I've raised PR 633: |
Comment by Mike Ferenduros (JIRA) Related: It looks like in Foundation, |
Comment by Chris Bailey (JIRA) Are you referring to That looks like the only point that Data is an optional, where yes we could fall back to |
Comment by Mike Ferenduros (JIRA) Yep, thats the one. Would it be useful for me to flesh out the tests with this stuff, and some more validations against httpbin.org for things like auth, redirection etc? |
Comment by Chris Bailey (JIRA) Absolutely - at the moment the tests we have are somewhat limited, so anything you can provide would be hugely valuable. |
Comment by Mike Ferenduros (JIRA) Cool 🙂 Working on it here: It's pretty early but I hit a few issues:
|
Comment by Andrey Fidrya (JIRA) Copying from PR 633: import Foundation
import Dispatch
var req = URLRequest(url: URL(string: "http://httpbin.org/post")!)
req.httpMethod = "POST"
req.httpBody = "a=b&c=d".data(using: .utf8)
//req.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
let sesh = URLSession(configuration: URLSessionConfiguration.default)
let dataTask1 = sesh.dataTask(with: req) { data, _, _ in
print(String(data: data!, encoding: .utf8)!)
}
dataTask1.resume()
let dataTask2 = sesh.dataTask(with: req) { data, _, _ in
print(String(data: data!, encoding: .utf8)!)
}
dataTask2.resume()
dispatchMain() |
Comment by sai Hema k (JIRA) klassobanieras (JIRA User) This issue seems to be fixed now.Can you please verify and close this ? |
Tested as working on both swift 4.2 and 5.1.4 |
Environment
swift-3.0-GM-CANDIDATE
Ubuntu 14.04.5 LTS (GNU/Linux 4.4.0-34-generic x86_64)
Additional Detail from JIRA
md5: 14dfeae41c1d30c4881bf7cdc79537be
Issue Description:
Sending a URLRequest with httpBody set, using URLSession.dataTask(), ignores the httpBody on Linux + corelibs-foundation. A body is only sent if passed directly to uploadTask().
The following illustrates the difference when run on Mac vs Linux:
The text was updated successfully, but these errors were encountered: