Add scheme before attempting URL parsing. (#75)
authorBrian Brazil <brian-brazil@users.noreply.github.com>
Sat, 5 Nov 2016 12:12:27 +0000 (12:12 +0000)
committerGitHub <noreply@github.com>
Sat, 5 Nov 2016 12:12:27 +0000 (12:12 +0000)
The url parsing is treating URLs without schemes
as paths rather than hosts.

http.go

diff --git a/http.go b/http.go
index 61550f527c3764230b8f3792b6630a61e39e427a..5bf947327ac9d35ee62ada5b710ebe7ada2763ec 100644 (file)
--- 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"
        }