From b96f0d37c9980211129389aa33327dda2d5d5e80 Mon Sep 17 00:00:00 2001 From: Ben Adrian Sarmiento Date: Sun, 16 Jun 2024 21:49:05 +0200 Subject: [PATCH] Reject non ok status codes --- pkg/http/ip.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/http/ip.go b/pkg/http/ip.go index d952c05..f65e3ef 100644 --- a/pkg/http/ip.go +++ b/pkg/http/ip.go @@ -204,6 +204,11 @@ func (r *IPRepository) testDomainLatency(client *HTTPClient, domain string) (flo retErr = err break } + if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusPartialContent { + r.log.Warnf("Failed to download from %s: %s", domain, resp.Status) + retErr = fmt.Errorf("status code: %s", resp.Status) + break + } limitedReader := io.LimitReader(resp.Body, testFileSize)