title: Reading from a Reader multiple times
body: <p>I'm building a simple caching proxy that intercepts HTTP requests, grabs the content in response.Body, then writes it back to the client. The problem is, as soon as I read from response.Body, the write back to the client contains an empty body (everything else, like the headers, are written as expected).</p>
  
  <p>Here's the current code:</p>
  
  <pre><code>func requestHandler(w http.ResponseWriter, r *http.Request) {
      client := &amp;http.Client{}
      r.RequestURI = ""
      response, err := client.Do(r)
      defer response.Body.Close()
      if err != nil {
          log.Fatal(err)
      }
      content, _ := ioutil.ReadAll(response.Body)
      cachePage(response.Request.URL.String(), content)
      response.Write(w)
  }
  </code></pre>
  
  <p>If I remove the <code>content, _</code> and <code>cachePage</code> lines, it works fine. With the lines included, requests return and empty body. Any idea how I can get <em>just</em> the <code>Body</code> of the <code>http.Response</code> and still write out the response in full to the <code>http.ResponseWriter</code>?</p>