Merge pull request #8 from Ferada/fix-read-status-code

Handle error response when reading a file.
This commit is contained in:
Christoph Polcin 2017-12-20 19:29:10 +01:00 committed by GitHub
commit f60c73fbb4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -261,7 +261,12 @@ func (c *Client) ReadStream(path string) (io.ReadCloser, error) {
if err != nil {
return nil, newPathErrorErr("ReadStream", path, err)
}
if rs.StatusCode == 200 {
return rs.Body, nil
} else {
rs.Body.Close()
return nil, newPathError("ReadStream", path, rs.StatusCode)
}
}
func (c *Client) Write(path string, data []byte, _ os.FileMode) error {