title: How to send post form data through a http client?
body: <p>I have a problem with post request, needed to send simple form data through http client.
  http.PostForm() is not ok because I need to set my own user agent and other headers.</p>
  <p>Here is the sample</p>
  <pre><code>func main() {
      formData := url.Values{
          &quot;form1&quot;: {&quot;value1&quot;},
          &quot;form2&quot;: {&quot;value2&quot;},
      }
  
      client := &amp;http.Client{}
      
      //Not working, the post data is not a form
      req, err := http.NewRequest(&quot;POST&quot;, &quot;http://test.local/api.php&quot;, strings.NewReader(formData.Encode()))
      if err != nil {
          log.Fatalln(err)
      }
      
      req.Header.Set(&quot;User-Agent&quot;, &quot;Golang_Super_Bot/0.1&quot;)
      
      resp, err := client.Do(req)
      if err != nil {
          log.Fatalln(err)
      }
      defer resp.Body.Close()
      
      body, err := ioutil.ReadAll(resp.Body)
      if err != nil {
          log.Fatalln(err)
      }
      
      log.Println(string(body))
  }
  </code></pre>