From 298dbc50ca355c7a5d327d362120a0cf1baf0342 Mon Sep 17 00:00:00 2001 From: Shireesh Anjal <355479+anjalshireesh@users.noreply.github.com> Date: Sun, 28 May 2023 23:32:33 +0530 Subject: [PATCH] fix proxy not being used to test connectivity (#4583) --- cmd/subnet-utils.go | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) 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 {