Reject non ok status codes

This commit is contained in:
Ben Adrian Sarmiento
2024-06-16 21:49:05 +02:00
parent 7e91eabeca
commit b96f0d37c9

View File

@@ -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)