Skip to content

Commit 76134c9

Browse files
Update jira.go
1 parent 8c40f10 commit 76134c9

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

onpremise/jira.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"encoding/json"
77
"fmt"
88
"io"
9+
"io/ioutil"
910
"net/http"
1011
"net/url"
1112
"reflect"
@@ -288,6 +289,7 @@ func (c *Client) Do(req *http.Request, v interface{}) (*Response, error) {
288289
if err != nil {
289290
return nil, err
290291
}
292+
defer httpResp.Body.Close()
291293

292294
err = CheckResponse(httpResp)
293295
if err != nil {
@@ -298,8 +300,11 @@ func (c *Client) Do(req *http.Request, v interface{}) (*Response, error) {
298300

299301
if v != nil {
300302
// Open a NewDecoder and defer closing the reader only if there is a provided interface to decode to
301-
defer httpResp.Body.Close()
302-
err = json.NewDecoder(httpResp.Body).Decode(v)
303+
body, err := ioutil.ReadAll(httpResp.Body)
304+
if err != nil {
305+
return newResponse(httpResp, nil), err
306+
}
307+
err = json.Unmarshal(body, v)
303308
}
304309

305310
resp := newResponse(httpResp, v)

0 commit comments

Comments
 (0)