|
|
@@ -11,6 +11,7 @@ import (
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
"io"
|
|
|
+ "io/ioutil"
|
|
|
"net"
|
|
|
"net/http"
|
|
|
"net/url"
|
|
|
@@ -134,13 +135,19 @@ func (c *Client) executeRequest(request *http.Request) (*Response, error) {
|
|
|
|
|
|
return nil, err
|
|
|
}
|
|
|
+ defer resp.Body.Close()
|
|
|
|
|
|
if resp.ContentLength > maxBodySize {
|
|
|
return nil, fmt.Errorf("client: response too large (%d bytes)", resp.ContentLength)
|
|
|
}
|
|
|
|
|
|
+ buf, err := ioutil.ReadAll(resp.Body)
|
|
|
+ if err != nil {
|
|
|
+ return nil, fmt.Errorf("client: error while reading body %v", err)
|
|
|
+ }
|
|
|
+
|
|
|
response := &Response{
|
|
|
- Body: resp.Body,
|
|
|
+ Body: bytes.NewReader(buf),
|
|
|
StatusCode: resp.StatusCode,
|
|
|
EffectiveURL: resp.Request.URL.String(),
|
|
|
LastModified: resp.Header.Get("Last-Modified"),
|