Skip to content

Commit

Permalink
Update jira.go
Browse files Browse the repository at this point in the history
  • Loading branch information
christopher-besch authored Jan 31, 2023
1 parent 0946977 commit d9cfdd6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions onpremise/jira.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/url"
"reflect"
Expand Down Expand Up @@ -288,6 +289,7 @@ func (c *Client) Do(req *http.Request, v interface{}) (*Response, error) {
if err != nil {
return nil, err
}
defer httpResp.Body.Close()

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

if v != nil {
// Open a NewDecoder and defer closing the reader only if there is a provided interface to decode to
defer httpResp.Body.Close()
err = json.NewDecoder(httpResp.Body).Decode(v)
body, err := ioutil.ReadAll(httpResp.Body)
if err != nil {
return newResponse(httpResp, nil), err
}
err = json.Unmarshal(body, v)
}

resp := newResponse(httpResp, v)
Expand Down

0 comments on commit d9cfdd6

Please sign in to comment.