From c5ba6d949d6f83a9e26ab6c132449ab5023f552b Mon Sep 17 00:00:00 2001 From: Niall Sheridan Date: Fri, 30 Sep 2016 21:51:26 -0700 Subject: Use json.NewDecoder to decode json from http --- client/client.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'client/client.go') diff --git a/client/client.go b/client/client.go index ba5b900..e69f353 100644 --- a/client/client.go +++ b/client/client.go @@ -5,7 +5,6 @@ import ( "crypto/tls" "encoding/json" "fmt" - "io/ioutil" "net/http" "net/url" "path" @@ -67,12 +66,8 @@ func send(s []byte, token, ca string, ValidateTLSCertificate bool) (*lib.SignRes return nil, fmt.Errorf("Bad response from server: %s", resp.Status) } defer resp.Body.Close() - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return nil, err - } c := &lib.SignResponse{} - if err := json.Unmarshal(body, c); err != nil { + if err := json.NewDecoder(resp.Body).Decode(c); err != nil { return nil, err } return c, nil -- cgit v1.2.3