title: how to close/abort a Golang http.Client POST prematurely
body: <p>I'm using <a href="http://golang.org/pkg/net/http/#Client" rel="noreferrer"><code>http.Client</code></a> for the client-side implementation of a long-poll:</p>
  
  <pre><code>resp, err := client.Post(url, "application/json", bytes.NewBuffer(jsonPostBytes))
  if err != nil {
      panic(err)
  }
  defer resp.Body.Close()
  
  var results []*ResponseMessage
  err = json.NewDecoder(resp.Body).Decode(&amp;results)  // code blocks here on long-poll
  </code></pre>
  
  <p><strong>Is there a standard way to pre-empt/cancel the request from the client-side?</strong> </p>
  
  <p>I imagine that calling <code>resp.Body.Close()</code> would do it, but I'd have to call that from another goroutine, as the client is normally already blocked in reading the response of the long-poll.</p>
  
  <p>I know that there is a way to set a timeout via <code>http.Transport</code>, but my app logic need to do the cancellation based on a user action, not just a timeout.</p>