In case of non 200 response return error

This commit is contained in:
Asim Aslam 2019-09-25 16:53:06 +01:00
parent 140e3d576c
commit dfcedbab1e

View File

@ -3,6 +3,7 @@ package http
import (
"encoding/json"
"errors"
"io/ioutil"
"net/http"
"net/url"
@ -58,7 +59,9 @@ func (r *Resolver) Resolve(name string) ([]*resolver.Record, error) {
return nil, err
}
defer rsp.Body.Close()
if rsp.StatusCode != 200 {
return nil, errors.New("non 200 response")
}
b, err := ioutil.ReadAll(rsp.Body)
if err != nil {
return nil, err