Browse code

excluding unused transformation to []byte

Signed-off-by: Igor Dolzhikov <bluesriverz@gmail.com>

Igor Dolzhikov authored on 2014/10/28 04:04:36
Showing 1 changed files
... ...
@@ -230,11 +230,7 @@ func (r *Session) GetRemoteTags(registries []string, repository string, token []
230 230
 		}
231 231
 
232 232
 		result := make(map[string]string)
233
-		rawJSON, err := ioutil.ReadAll(res.Body)
234
-		if err != nil {
235
-			return nil, err
236
-		}
237
-		if err := json.Unmarshal(rawJSON, &result); err != nil {
233
+		if err := json.NewDecoder(res.Body).Decode(&result); err != nil {
238 234
 			return nil, err
239 235
 		}
240 236
 		return result, nil
... ...
@@ -305,12 +301,8 @@ func (r *Session) GetRepositoryData(remote string) (*RepositoryData, error) {
305 305
 		endpoints = append(endpoints, fmt.Sprintf("%s://%s/v1/", r.indexEndpoint.URL.Scheme, req.URL.Host))
306 306
 	}
307 307
 
308
-	checksumsJSON, err := ioutil.ReadAll(res.Body)
309
-	if err != nil {
310
-		return nil, err
311
-	}
312 308
 	remoteChecksums := []*ImgData{}
313
-	if err := json.Unmarshal(checksumsJSON, &remoteChecksums); err != nil {
309
+	if err := json.NewDecoder(res.Body).Decode(&remoteChecksums); err != nil {
314 310
 		return nil, err
315 311
 	}
316 312
 
... ...
@@ -590,12 +582,8 @@ func (r *Session) SearchRepositories(term string) (*SearchResults, error) {
590 590
 	if res.StatusCode != 200 {
591 591
 		return nil, utils.NewHTTPRequestError(fmt.Sprintf("Unexepected status code %d", res.StatusCode), res)
592 592
 	}
593
-	rawData, err := ioutil.ReadAll(res.Body)
594
-	if err != nil {
595
-		return nil, err
596
-	}
597 593
 	result := new(SearchResults)
598
-	err = json.Unmarshal(rawData, result)
594
+	err = json.NewDecoder(res.Body).Decode(result)
599 595
 	return result, err
600 596
 }
601 597