From: Brian Brazil Date: Sat, 5 Nov 2016 12:12:27 +0000 (+0000) Subject: Add scheme before attempting URL parsing. (#75) X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=5c6496b80d0ee5d8f7983fe9dd6a00edcb6de9c8;p=blackbox_exporter.git Add scheme before attempting URL parsing. (#75) The url parsing is treating URLs without schemes as paths rather than hosts. --- diff --git a/http.go b/http.go index 61550f5..5bf9473 100644 --- a/http.go +++ b/http.go @@ -74,6 +74,9 @@ func probeHTTP(target string, w http.ResponseWriter, module Module) (success boo } else { fallbackProtocol = "ip6" } + if !strings.HasPrefix(target, "http://") && !strings.HasPrefix(target, "https://") { + target = "http://" + target + } dialProtocol = module.HTTP.Protocol if module.HTTP.Protocol == "tcp" { @@ -132,9 +135,6 @@ func probeHTTP(target string, w http.ResponseWriter, module Module) (success boo return nil } - if !strings.HasPrefix(target, "http://") && !strings.HasPrefix(target, "https://") { - target = "http://" + target - } if config.Method == "" { config.Method = "GET" }