aboutsummaryrefslogtreecommitdiffhomepage
path: root/http
diff options
context:
space:
mode:
Diffstat (limited to 'http')
-rw-r--r--http/client/client.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/http/client/client.go b/http/client/client.go
index 7663064..cba55c4 100644
--- a/http/client/client.go
+++ b/http/client/client.go
@@ -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"),