Skip to content

Commit

Permalink
Merge pull request #14 from fnaoto/2022-06-09
Browse files Browse the repository at this point in the history
Fix response body.
  • Loading branch information
fnaoto authored Jun 9, 2022
2 parents 1aab774 + 79d78d9 commit 6637f84
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package deploygate

import (
"bytes"
"encoding/json"
"errors"
"fmt"
Expand Down Expand Up @@ -107,7 +108,9 @@ func (c *Client) NewRequest(httpRequest *HttpRequest) (*http.Response, error) {
func (c *Client) Decode(resp *http.Response, out interface{}) error {
defer resp.Body.Close()
if resp.StatusCode >= 300 {
return fmt.Errorf("status code is %v, body is %v", resp.StatusCode, resp.Body)
buf := new(bytes.Buffer)
buf.ReadFrom(resp.Body)
return fmt.Errorf("status code is %v, body is %v", resp.StatusCode, buf.String())
}
if resp.ContentLength == 0 {
return nil
Expand Down

0 comments on commit 6637f84

Please sign in to comment.