I have a swift app. It sends http requests to a server that I cannot access myself.
When the app is at the background for a while, and I return and try to send a request to the server I get an http error "the connection is lost".
I read this post
And I want to add connection:close header and value, as suggested.
I have tried this code:
func taskForGETMethod(method: String, pathParameters: [String], parameters: [String : AnyObject], completionHandler: (result: AnyObject!, error: NSError?) -> Void) -> NSURLSessionDataTask {
/* 1. Build the URL and configure the request */
let urlString = Constants.BaseURLSecure + method + HttpClient.escapedPath(pathParameters) + HttpClient.escapedParameters(parameters)
let url = NSURL(string: urlString)!
let request = NSURLRequest(URL: url)
request.setValue("Connection", forKey: "close")
but all my request's are failing now. How can I add the header correctly?