1
0
mirror of https://github.com/interviewstreet/go-jira.git synced 2025-06-14 23:45:03 +02:00

Bug fix - reading http body produces error because the body is already read

This commit is contained in:
Kent Brockman
2016-05-23 23:48:04 -06:00
parent 559b76c3ef
commit 8e67015ef3
2 changed files with 29 additions and 2 deletions

View File

@ -97,8 +97,6 @@ func (c *Client) Do(req *http.Request, v interface{}) (*http.Response, error) {
return nil, err
}
defer resp.Body.Close()
err = CheckResponse(resp)
if err != nil {
// Even though there was an error, we still return the response
@ -107,6 +105,8 @@ func (c *Client) Do(req *http.Request, v interface{}) (*http.Response, error) {
}
if v != nil {
// Open a NewDecoder and defer closing the reader only if there is a provided interface to decode to
defer resp.Body.Close()
err = json.NewDecoder(resp.Body).Decode(v)
}