Skip to content

Commit

Permalink
fix: get cookie response body on error
Browse files Browse the repository at this point in the history
  • Loading branch information
powersj committed Jul 8, 2022
1 parent a9e71ee commit 49c19f3
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions plugins/common/cookie/cookie.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,16 @@ func (c *CookieAuthConfig) auth() error {
}
defer resp.Body.Close()

if _, err = io.Copy(io.Discard, resp.Body); err != nil {
respBody, err := io.ReadAll(resp.Body)
if err != nil {
return err
}

if resp.StatusCode != http.StatusOK {
return fmt.Errorf("cookie auth renewal received status code: %v (%v)",
if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusCreated {
return fmt.Errorf("cookie auth renewal received status code: %v (%v) - %v",
resp.StatusCode,
http.StatusText(resp.StatusCode),
string(respBody),
)
}

Expand Down

0 comments on commit 49c19f3

Please sign in to comment.