diff --git a/cmd/subnet-utils.go b/cmd/subnet-utils.go index 4ff0d6c9..480576b5 100644 --- a/cmd/subnet-utils.go +++ b/cmd/subnet-utils.go @@ -129,19 +129,10 @@ func subnetMFAURL() string { } func checkURLReachable(url string) *probe.Error { - clnt := httpClient(10 * time.Second) - req, e := http.NewRequest(http.MethodHead, url, nil) + _, e := subnetHeadReq(url, nil) if e != nil { return probe.NewError(e).Trace(url) } - resp, e := clnt.Do(req) - if e != nil { - return probe.NewError(e).Trace(url) - } - defer resp.Body.Close() - if resp.StatusCode != http.StatusOK { - return probe.NewError(errors.New(resp.Status)).Trace(url) - } return nil } @@ -219,6 +210,14 @@ func subnetReqDo(r *http.Request, headers map[string]string) (string, error) { return respStr, fmt.Errorf("Request failed with code %d with error: %s", resp.StatusCode, respStr) } +func subnetHeadReq(reqURL string, headers map[string]string) (string, error) { + r, e := http.NewRequest(http.MethodHead, reqURL, nil) + if e != nil { + return "", e + } + return subnetReqDo(r, headers) +} + func subnetGetReq(reqURL string, headers map[string]string) (string, error) { r, e := http.NewRequest(http.MethodGet, reqURL, nil) if e != nil {