URLSession GET with httpBody hangs
| Originator: | jsambuo | ||
| Number: | rdar://29757521 | Date Originated: | 12/20/2016 |
| Status: | Open | Resolved: | |
| Product: | iOS + SDK | Product Version: | iOS 10.0 |
| Classification: | Foundation | Reproducible: | Yes |
I'm trying to send an HTTP GET with some data in the body. The HTTP Request says the Content-Length is greater than 0, but no body is sent. A minute later, the response comes back saying "The request timed out." I'm expecting the request to succeed by sending the body to the server.
This was discussed a bit in https://forums.developer.apple.com/thread/67143
Steps to Reproduce:
Run this code in the simulator:
let session = URLSession(configuration: URLSessionConfiguration.default, delegate: nil, delegateQueue: nil)
var request = URLRequest(url: URL(string:"https://www.example.com")!)
request.httpMethod = "GET"
request.httpBody = try! JSONSerialization.data(withJSONObject: [], options: .prettyPrinted)
let task = session.dataTask(with: request) { (data, response, error) in
print("Got response")
print(data)
print(response)
print(error)
}
task.resume()
Expected Results:
The response should come back successfully in under three seconds.
Actual Results:
The response takes over 30 seconds and times out.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!