In case of non 200 response return error
This commit is contained in:
parent
140e3d576c
commit
dfcedbab1e
@ -3,6 +3,7 @@ package http
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
@ -58,7 +59,9 @@ func (r *Resolver) Resolve(name string) ([]*resolver.Record, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer rsp.Body.Close()
|
defer rsp.Body.Close()
|
||||||
|
if rsp.StatusCode != 200 {
|
||||||
|
return nil, errors.New("non 200 response")
|
||||||
|
}
|
||||||
b, err := ioutil.ReadAll(rsp.Body)
|
b, err := ioutil.ReadAll(rsp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Loading…
x
Reference in New Issue
Block a user