diff --git a/prober.go b/prober.go index c917cfd..9431c10 100644 --- a/prober.go +++ b/prober.go @@ -3,6 +3,7 @@ package probing import ( "encoding/json" "errors" + "fmt" "net/http" "sync" "time" @@ -60,6 +61,10 @@ func (p *prober) AddHTTP(id string, probingInterval time.Duration, endpoints []s panic(err) } resp, err := p.tr.RoundTrip(req) + if err == nil && resp.StatusCode != http.StatusOK { + err = fmt.Errorf("got unexpected HTTP status code %s from %s", resp.Status, endpoints[pinned]) + resp.Body.Close() + } if err != nil { s.recordFailure(err) pinned = (pinned + 1) % len(endpoints)