fix: context cancel (#1350)

Co-authored-by: Asim Aslam <asim@aslam.me>
This commit is contained in:
li.peng 2020-03-16 18:45:33 +08:00 committed by GitHub
parent ac333d9d47
commit 5712aafba9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -98,10 +98,12 @@ func newWatcher(req *api.Request) (Watcher, error) {
// do the raw request
res, err := req.Raw()
if err != nil {
cancel()
return nil, err
}
if res.StatusCode < 200 || res.StatusCode >= 300 {
cancel()
// close the response body
res.Body.Close()
// return an error