title: Sending POST request in Golang with header
body: <p>I create my form like this:</p>
  
  <pre><code>form := url.Values{}
  form.Add("region", "San Francisco")
  if len(params) &gt; 0 { 
      for i := 0; i &lt; len(params); i += 2 { 
          form.Add(params[i], params[i+1])
      }
      testLog.Infof("form %v", form)
  </code></pre>
  
  <p>Now if I use</p>
  
  <pre><code>resp, err = http.PostForm(address+r.Path, form)
  </code></pre>
  
  <p>then everything works fine, I get back a response with an expected cookie.  </p>
  
  <p>However, I would like to to add a header in which case I can't use <code>PostForm</code> hence I created my <code>POST request</code> manually like:</p>
  
  <pre><code>req, err := http.NewRequest("POST", address+r.Path, strings.NewReader(form.Encode()))
  </code></pre>
  
  <p>Then I add stuff to the header and send the request</p>
  
  <pre><code>req.Header.Add("region", "San Francisco") 
  resp, err = http.DefaultClient.Do(req)
  </code></pre>
  
  <p>But the form is not received and my response does not contain any cookie.</p>
  
  <p>When I print the <code>req</code>, it looks like the form is <code>nil</code>:</p>
  
  <pre><code>&amp;{POST http://localhost:8081/login HTTP/1.1 1 1 map[Region:[San Francisco]] {0xc420553600} 78 [] false localhost:8081 map[] map[] &lt;nil&gt; map[]   &lt;nil&gt; &lt;nil&gt; &lt;nil&gt; &lt;nil&gt;}
  </code></pre>