Fix body closing in List method

This commit is contained in:
Jeff Mitchell 2015-09-14 17:30:42 -04:00
parent 10c307763e
commit d17c3f4407

View file

@ -29,13 +29,15 @@ func (c *Logical) Read(path string) (*Secret, error) {
func (c *Logical) List(path string) (*Secret, error) {
r := c.c.NewRequest("LIST", "/v1/"+path)
resp, err := c.c.RawRequest(r)
if resp != nil {
defer resp.Body.Close()
}
if resp != nil && resp.StatusCode == 404 {
return nil, nil
}
if err != nil {
return nil, err
}
defer resp.Body.Close()
return ParseSecret(resp.Body)
}