You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The behavior of URL requests for a `POST` method with no post body and no `Content-type` header is inconsistent between MacOS and Linux.
In Linux, a `Content-type` header is added to the request:
```
Content-Type:application/x-www-form-urlencoded
```
In MacOS, no `Content-type` header is added.
Note that this behavior is for the specific case of no post body – i.e. the `content-length` is 0. When `content-length` is > 0, both platforms add the Content-type header when none is specified.
The following simple test case illustrates the problem (thanks to Nethra Ravindran):
```
import Foundation
import Dispatch
Additional Detail from JIRA
md5: 38c676a286d8708d400982155a8ed41c
Issue Description:
The behavior of URL requests for a `POST` method with no post body and no `Content-type` header is inconsistent between MacOS and Linux.
In Linux, a `Content-type` header is added to the request:
```
Content-Type:application/x-www-form-urlencoded
```
In MacOS, no `Content-type` header is added.
Note that this behavior is for the specific case of no post body – i.e. the `content-length` is 0. When `content-length` is > 0, both platforms add the Content-type header when none is specified.
The following simple test case illustrates the problem (thanks to Nethra Ravindran):
```
import Foundation
import Dispatch
var req = URLRequest(url: URL(string: "http://httpbin.org/post")!)
req.httpMethod = "POST"
let urlSession = URLSession(configuration: URLSessionConfiguration.default)
let dataTask = urlSession.dataTask(with: req) { data, response, error in
print(String(data: data![](, encoding: .utf8)))
exit(0)
}
dataTask.resume()
dispatchMain()
```
The text was updated successfully, but these errors were encountered: