title: How can I add the http header "Connection :close" correctly in swift?
body: <p>I have a swift app. It sends http requests to a server that I cannot access myself.</p>
  
  <p>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".</p>
  
  <p>I read this <a href="https://stackoverflow.com/a/25996971/311130">post</a></p>
  
  <p>And I want to add connection:close header and value, as suggested.</p>
  
  <p>I have tried this code:</p>
  
  <pre><code>func taskForGETMethod(method: String, pathParameters: [String], parameters: [String : AnyObject], completionHandler: (result: AnyObject!, error: NSError?) -&gt; Void) -&gt; 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")
  </code></pre>
  
  <p>but all my request's are failing now. How can I add the header correctly?</p>