title: How to make a Http get and set httpHeader in Swift?
body: <p>I have try to make a HTTP Get in Objective-C. </p>
  
  <p>It use the <code>NSMutableURLRequest *request;</code> in <code>Objective-C</code>, and use <code>[request setHTTPMethod:@"GET"];</code> to select <code>GET</code> or <code>POST</code>.</p>
  
  <p>And set the Header via following code:</p>
  
  <pre><code>[request setValue:@"Application/json" forHTTPHeaderField:@"Accept"];
  [request addValue:@"Application/json" forHTTPHeaderField:@"Content-Type"];
  [request addValue:[NSString stringWithFormat:@"Basic %@",USER_PWD] forHTTPHeaderField:@"Authorization"];
  </code></pre>
  
  <p>I reference the link <a href="https://stackoverflow.com/questions/24016142/how-to-make-an-http-request-in-swift">How to make an HTTP request in Swift?</a>, and it only show the following code:</p>
  
  <pre><code>let url = NSURL(string: "http://www.stackoverflow.com")
  let request = NSURLRequest(URL: url)
  
  NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue.mainQueue()) {(response, data, error) in
      println(NSString(data: data, encoding: NSUTF8StringEncoding))
  }
  </code></pre>
  
  <p>But it didn't select <code>Get</code> or <code>Post</code> , and it also didn't set the header.
  <strong>How to decide the Http method is <code>Get</code> or <code>Post</code>? and how to set the Header? in Swift</strong></p>
  
  <p>Thanks in advance.</p>