1
0
Fork 0
mirror of https://gitlab.com/pnx-tools/dns-updater.git synced 2026-06-16 05:54:56 +02:00

ip/resolver/basic_http/service.go: return error on http status != 2xx

This commit is contained in:
Henrik Hautakoski 2023-12-01 21:51:38 +01:00
parent e0a4b6ee95
commit 6df2eb3971

View file

@ -1,6 +1,7 @@
package basic_http
import (
"fmt"
"io"
"net"
"net/http"
@ -30,6 +31,10 @@ func (s Service) Lookup() (net.IP, error) {
return nil, err
}
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
return nil, fmt.Errorf("HTTP Response: %s", resp.Status)
}
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err