White
(LLLL)
1
When use URLRequest, set httpMethod to GET, and set some no-empty Data to HTTPBody, is that correct that URLRequest just calculate content-length by HTTPBody.count? Because when i check RFC of HTTP, it's said that there is no-meaning of messageBody in Get request, so should it be zero when URLRequest found that HTTPMethod is Get?
eskimo
(Quinn “The Eskimo!”)
2
When use URLRequest …
Are you targeting an Apple platform? Or Linux?
Share and Enjoy
Quinn “The Eskimo!” @ DTS @ Apple
White
(LLLL)
3
Target is Apple Platform, iOS.
Jon_Shier
(Jon Shier)
4
As of the 2019 OSes, URLRequests with a GET httpMethod and non-nil body data is considered an error, and URLSession will fail any task trying to perform one. Previously, URLSession didn't throw an error but also didn't set the Content-Length when performing the request, leading it to fail. Even if you manually set Content-Length, servers don't usually support GET requests with body data anyway.
2 Likes
White
(LLLL)
5
Thanks for your reoly.
I have some question:
What's is 2019 OSes
Is it iOS13&macOS10.15?
URLSession will fail any task trying to perform one
so URLSession will directly return error and don't send and HTTP Request to Server?
Thanks.
Jon_Shier
(Jon Shier)
6
Yes, in iOS 13, macOS 10.15, etc., URLSession will immediately fail the task before sending it over the network, per Apple's release notes:
Previous versions will have a network failure error of some kind.
2 Likes
White
(LLLL)
7
Thanks a lot, i should read iOS release notes carefully.