title: Unexpected http/net response content length in Golang
body: <p>I am making a HTTP Get request using the code below. I proxy it through Fiddler to analyse the request. The request seems to be being made correctly, with the expected response. However, the <code>resp.ContentLength</code> property of the response in GO is <code>-1</code> 
  every time despite the fact that the response in Fiddler shows a positive integer value of <code>Content-Length: 1830</code>.</p>
  
  <p>Why is the ContentLength not being picked up in GO?</p>
  
  <p><strong>Go Code</strong></p>
  
  <pre><code>package main
  
  import "net/http"
  import "os"
  import "fmt"
  
  func main() {
      os.Setenv("HTTP_PROXY", "http://127.0.0.1:8888") // For Fiddler debugging
      resp,err := http.Get("http://www.google.com/robots.txt")
      if (err == nil) {
          if (resp.StatusCode == 200) {
              fmt.Println(resp.ContentLength) // Prints -1
          }
      }
  }
  </code></pre>
  
  <p><strong>Resulting Request in Fiddler</strong></p>
  
  <pre><code>GET /robots.txt HTTP/1.1
  Host: www.google.com
  User-Agent: Go-http-client/1.1
  Accept-Encoding: gzip
  </code></pre>
  
  <p><strong>Response Received in Fiddler</strong></p>
  
  <pre><code>HTTP/1.1 200 OK
  Accept-Ranges: bytes
  Vary: Accept-Encoding
  Content-Type: text/plain
  Content-Length: 6907
  Date: Mon, 05 Mar 2018 13:53:00 GMT
  Expires: Mon, 05 Mar 2018 13:53:00 GMT
  Cache-Control: private, max-age=0
  Last-Modified: Thu, 01 Mar 2018 18:00:00 GMT
  X-Content-Type-Options: nosniff
  Server: sffe
  X-XSS-Protection: 1; mode=block
  </code></pre>