don't use ReadAll when decoding JSON

An empty stream isn't valid JSON, so we shouldn't silently ignore it.
This commit is contained in:
Daniel Martí
2019-05-27 11:02:50 +01:00
parent 098d963881
commit 9bcdcc128f
11 changed files with 29 additions and 53 deletions
+2 -1
View File
@@ -1,6 +1,7 @@
package jira
import (
"encoding/json"
"net/http"
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiradata"
@@ -8,7 +9,7 @@ import (
func responseError(resp *http.Response) error {
results := &jiradata.ErrorCollection{}
if err := readJSON(resp.Body, results); err != nil {
if err := json.NewDecoder(resp.Body).Decode(results); err != nil {
results.Status = resp.StatusCode
results.ErrorMessages = append(results.ErrorMessages, err.Error())
}